Skip to content

Commit

Permalink
[EuiFilterButton] Allow for zero notifications
Browse files Browse the repository at this point in the history
The existing check implicitly disallows `0`, which causes the
rendered `0` to lack the proper styling.
  • Loading branch information
pickypg committed Feb 2, 2019
1 parent ca798f6 commit f032638
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,29 @@ exports[`EuiFilterButton is rendered 1`] = `
</span>
</button>
`;

exports[`EuiFilterButton renders zero properly 1`] = `
<button
aria-label="aria-label"
class="euiButtonEmpty euiButtonEmpty--text euiButtonEmpty--iconRight euiFilterButton testClass1 testClass2"
data-test-subj="test subject string"
type="button"
>
<span
class="euiButtonEmpty__content"
>
<span
class="euiButtonEmpty__text"
>
<span
class="euiFilterButton__textShift"
/>
<span
class="euiNotificationBadge euiFilterButton__notification"
>
0
</span>
</span>
</span>
</button>
`;
2 changes: 1 addition & 1 deletion src/components/filter_group/filter_button.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const EuiFilterButton = ({
<span className="euiFilterButton__textShift" data-text={children}>
{children}
</span>
{numFilters &&
{numFilters != null &&
<EuiNotificationBadge className="euiFilterButton__notification">{numFilters}</EuiNotificationBadge>
}
</Fragment>
Expand Down
8 changes: 8 additions & 0 deletions src/components/filter_group/filter_button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ describe('EuiFilterButton', () => {
expect(component)
.toMatchSnapshot();
});

test('renders zero properly', () => {
const component = render(
<EuiFilterButton {...requiredProps} numFilters={0} />
);

expect(component).toMatchSnapshot();
});
});

0 comments on commit f032638

Please sign in to comment.