Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Button should render text if text={0} #2727

Merged
merged 4 commits into from
Jul 30, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/components/button/abstractButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export abstract class AbstractButton<H extends React.HTMLAttributes<any>> extend
return [
loading && <Spinner key="loading" className={Classes.BUTTON_SPINNER} size={Icon.SIZE_LARGE} />,
<Icon key="leftIcon" icon={icon} />,
(text || children) && (
((text != null && text !== "") || children) && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also make it children != null for the same reason?

<span key="text" className={Classes.BUTTON_TEXT}>
{text}
{children}
Expand Down
5 changes: 5 additions & 0 deletions packages/core/test/buttons/buttonTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ function buttonTestSuite(component: React.ComponentClass<any>, tagName: string)
assert.equal(wrapper.text(), "some text");
});

it("renders the button text prop when text={0}", () => {
const wrapper = button({ text: 0 }, true);
assert.equal(wrapper.text(), "0");
});

it("wraps string children in spans", () => {
// so text can be hidden when loading
const wrapper = button({}, true, "raw string", <em>not a string</em>);
Expand Down