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

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

merged 4 commits into from
Jul 30, 2018

Conversation

badams
Copy link
Contributor

@badams badams commented Jul 25, 2018

Fixes #2703

Changes proposed in this pull request:

Instead of checking if the text prop is truthy, check if it is defined and not an empty string.

Reviewers should focus on:

I've added an extra check (text != null && text !== "") to prevent a regression of the issue addressed in 540b88b.

This regression was not picked up by the unit test here because the test in question is only checking if children="" rather than testing the text prop.

I think another assertion should be added:

assert.equal(button({text:""}, true).find("span").length, 0);

screen shot 2018-07-26 at 10 29 14 am

<Button icon="edit" />
<Button text="" icon="edit" />

Copy link
Contributor

@giladgray giladgray left a comment

Choose a reason for hiding this comment

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

yes please add that other test you suggested!

@@ -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?

Copy link
Contributor

@giladgray giladgray left a comment

Choose a reason for hiding this comment

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

nice 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants