Skip to content

Commit

Permalink
IndexFilters replace custom FilterButton with polaris Button invoca…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
gwyneplaine committed Aug 28, 2023
1 parent 3c9da97 commit 55a984c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 45 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Icon} from '../../../Icon';
import {Tooltip} from '../../../Tooltip';
import {Text} from '../../../Text';
import {InlineStack} from '../../../InlineStack';
import {FilterButton} from '../FilterButton';
import {Button} from '../../../Button';

export interface SearchFilterButtonProps {
onClick: () => void;
Expand Down Expand Up @@ -36,11 +36,12 @@ export function SearchFilterButton({

const activator = (
<div style={style}>
<FilterButton
<Button
size="slim"
onClick={onClick}
label={label}
disabled={disabled}
icon={iconMarkup}
accessibilityLabel={label}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {ChoiceListProps} from '../../../ChoiceList';
import {Tooltip} from '../../../Tooltip';
import {Box} from '../../../Box';
import type {SortButtonChoice} from '../../types';
import {FilterButton} from '../FilterButton';
import {Button} from '../../../Button';

import {DirectionButton} from './components';

Expand Down Expand Up @@ -100,11 +100,14 @@ export function SortButton({
preferredPosition="above"
hoverDelay={400}
>
<FilterButton
<Button
size="slim"
icon={SortMinor}
onClick={handleClick}
label={i18n.translate('Polaris.IndexFilters.SortButton.ariaLabel')}
disabled={disabled}
accessibilityLabel={i18n.translate(
'Polaris.IndexFilters.SortButton.ariaLabel',
)}
/>
</Tooltip>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {SortButtonChoice} from '../../../types';
import {SortButton} from '..';
import type {SortButtonProps} from '../SortButton';
import {DirectionButton} from '../components';
import {FilterButton} from '../..';
import {Button} from '../../../../Button';

describe('SortButton', () => {
const choices: SortButtonChoice[] = [
Expand Down Expand Up @@ -63,15 +63,15 @@ describe('SortButton', () => {
const wrapper = mountWithApp(<SortButton {...props} />);

wrapper.act(() => {
wrapper.find(FilterButton)!.trigger('onClick');
wrapper.find(Button)!.trigger('onClick');
});

expect(wrapper).toContainReactComponent(Popover, {
active: true,
});

wrapper.act(() => {
wrapper.find(FilterButton)!.trigger('onClick');
wrapper.find(Button)!.trigger('onClick');
});

expect(wrapper).toContainReactComponent(Popover, {
Expand All @@ -88,7 +88,7 @@ describe('SortButton', () => {
const wrapper = mountWithApp(<SortButton {...props} />);

wrapper.act(() => {
wrapper.find(FilterButton)!.trigger('onClick');
wrapper.find(Button)!.trigger('onClick');
});

wrapper.act(() => {
Expand All @@ -107,7 +107,7 @@ describe('SortButton', () => {
const wrapper = mountWithApp(<SortButton {...props} />);

wrapper.act(() => {
wrapper.find(FilterButton)!.trigger('onClick');
wrapper.find(Button)!.trigger('onClick');
});

expect(wrapper).toContainReactComponent(DirectionButton, {
Expand All @@ -125,7 +125,7 @@ describe('SortButton', () => {
const wrapper = mountWithApp(<SortButton {...props} />);

wrapper.act(() => {
wrapper.find(FilterButton)!.trigger('onClick');
wrapper.find(Button)!.trigger('onClick');
});

expect(wrapper).toContainReactComponent(DirectionButton, {
Expand All @@ -143,7 +143,7 @@ describe('SortButton', () => {
const wrapper = mountWithApp(<SortButton {...props} />);

wrapper.act(() => {
wrapper.find(FilterButton)!.trigger('onClick');
wrapper.find(Button)!.trigger('onClick');
});

wrapper.act(() => {
Expand All @@ -165,7 +165,7 @@ describe('SortButton', () => {
const wrapper = mountWithApp(<SortButton {...props} />);

wrapper.act(() => {
wrapper.find(FilterButton)!.trigger('onClick');
wrapper.find(Button)!.trigger('onClick');
});

wrapper.act(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export {Container} from './Container';
export {FilterButton} from './FilterButton';
export {SearchFilterButton} from './SearchFilterButton';
export {SortButton} from './SortButton';
export {UpdateButtons} from './UpdateButtons';
1 change: 0 additions & 1 deletion polaris-react/src/components/IndexFilters/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export {IndexFilters} from './IndexFilters';
export {SortButton} from './components/SortButton/SortButton';
export {FilterButton} from './components/FilterButton';
export type {IndexFiltersProps} from './IndexFilters';
export * from './hooks';
export * from './types';

0 comments on commit 55a984c

Please sign in to comment.