Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Commit b459f2e

Browse files
sirgalletochloericemrcthms
committed
Apply suggestions from code review
Co-authored-by: Chloe Rice <chloerice@users.noreply.github.com> Co-authored-by: Marc Thomas <marc.thomas@shopify.com>
1 parent 10cb148 commit b459f2e

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

.changeset/strange-bananas-obey.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'@shopify/polaris': minor
33
---
44

5-
Add Edit Columns button on `IndexFilters` when showEditColumns flag is true
5+
Added the `showEditColumnsButton` prop to `IndexFilters`

polaris-react/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@
194194
}
195195
},
196196
"EditColumnsButton": {
197-
"editColumns": "Edit columns"
197+
"tooltip": "Edit columns",
198+
"accessibilityLabel": "Customize table column order and visibility"
198199
},
199200
"UpdateButtons": {
200201
"cancel": "Cancel",

polaris-react/src/components/IndexFilters/IndexFilters.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ export function Default() {
385385
}
386386

387387
export function WithEditColumsButton() {
388-
return <BasicExample showEditColumns />;
388+
return <BasicExample showEditColumnsButton />;
389389
}
390390

391391
export function WithoutKeyboardShortcuts() {
@@ -936,7 +936,7 @@ export function Disabled() {
936936
mode={mode}
937937
setMode={setMode}
938938
disabled
939-
showEditColumns
939+
showEditColumnsButton
940940
/>
941941
<Table />
942942
</Card>

polaris-react/src/components/IndexFilters/IndexFilters.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ export interface IndexFiltersProps
103103
closeOnChildOverlayClick?: boolean;
104104
/** Optional override to the default keyboard shortcuts available */
105105
disableKeyboardShortcuts?: boolean;
106-
/** Shows the edit columns button */
107-
showEditColumns?: boolean;
106+
/** Whether to display the edit columns button with the other default mode filter actions */
107+
showEditColumnsButton?: boolean;
108108
}
109109

110110
export function IndexFilters({
@@ -143,7 +143,7 @@ export function IndexFilters({
143143
hideQueryField,
144144
closeOnChildOverlayClick,
145145
disableKeyboardShortcuts,
146-
showEditColumns,
146+
showEditColumnsButton,
147147
}: IndexFiltersProps) {
148148
const i18n = useI18n();
149149
const {mdDown} = useBreakpoints();
@@ -288,7 +288,7 @@ export function IndexFilters({
288288
beginEdit(IndexFiltersMode.EditingColumns);
289289
}
290290

291-
const editColumnsMarkup = showEditColumns ? (
291+
const editColumnsMarkup = showEditColumnsButton ? (
292292
<EditColumnsButton
293293
onClick={handleClickEditColumnsButon}
294294
disabled={disabled}

polaris-react/src/components/IndexFilters/components/EditColumnsButton/EditColumnsButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function EditColumnsButton({onClick, disabled}: EditColumnsButtonProps) {
1919

2020
const tooltipContent = (
2121
<Text as="span" variant="bodyMd" alignment="center">
22-
{i18n.translate('Polaris.IndexFilters.EditColumnsButton.editColumns')}
22+
{i18n.translate('Polaris.IndexFilters.EditColumnsButton.tooltip')}
2323
</Text>
2424
);
2525

@@ -33,7 +33,7 @@ export function EditColumnsButton({onClick, disabled}: EditColumnsButtonProps) {
3333
onClick={onClick}
3434
icon={polarisSummerEditions2023 ? Columns3Minor : undefined}
3535
label={i18n.translate(
36-
'Polaris.IndexFilters.EditColumnsButton.editColumns',
36+
'Polaris.IndexFilters.EditColumnsButton.accessibilityLabel',
3737
)}
3838
disabled={disabled}
3939
>

polaris-react/src/components/IndexFilters/tests/IndexFilters.test.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('IndexFilters', () => {
9090
setMode: jest.fn(),
9191
canCreateNewView: true,
9292
onCreateNewView: jest.fn(),
93-
showEditColumns: false,
93+
showEditColumnsButton: false,
9494
};
9595

9696
beforeEach(() => {
@@ -431,7 +431,7 @@ describe('IndexFilters', () => {
431431

432432
it('renders EditColumnsButton with the disabled prop', () => {
433433
const wrapper = mountWithApp(
434-
<IndexFilters {...defaultProps} disabled showEditColumns />,
434+
<IndexFilters {...defaultProps} disabled showEditColumnsButton />,
435435
);
436436

437437
expect(wrapper).toContainReactComponent(EditColumnsButton, {
@@ -441,17 +441,17 @@ describe('IndexFilters', () => {
441441
});
442442

443443
describe('EditColumnsButton', () => {
444-
it('renders when showEditColumns is true', () => {
444+
it('renders when showEditColumnsButton is true', () => {
445445
const wrapper = mountWithApp(
446-
<IndexFilters {...defaultProps} showEditColumns />,
446+
<IndexFilters {...defaultProps} showEditColumnsButton />,
447447
);
448448

449449
expect(wrapper).toContainReactComponent(EditColumnsButton);
450450
});
451451

452-
it('does not renders when showEditColumns is false', () => {
452+
it('does not renders when showEditColumnsButton is false', () => {
453453
const wrapper = mountWithApp(
454-
<IndexFilters {...defaultProps} showEditColumns={false} />,
454+
<IndexFilters {...defaultProps} showEditColumnsButton={false} />,
455455
);
456456

457457
expect(wrapper).not.toContainReactComponent(EditColumnsButton);
@@ -461,7 +461,7 @@ describe('IndexFilters', () => {
461461
'does not renders when IndexFiltersMode is %s',
462462
(mode: IndexFiltersMode) => {
463463
const wrapper = mountWithApp(
464-
<IndexFilters {...defaultProps} mode={mode} showEditColumns />,
464+
<IndexFilters {...defaultProps} mode={mode} showEditColumnsButton />,
465465
);
466466

467467
expect(wrapper).not.toContainReactComponent(EditColumnsButton);
@@ -471,7 +471,11 @@ describe('IndexFilters', () => {
471471
it('sets mode to EditingColumns when clicked', () => {
472472
const setMode = jest.fn();
473473
const wrapper = mountWithApp(
474-
<IndexFilters {...defaultProps} setMode={setMode} showEditColumns />,
474+
<IndexFilters
475+
{...defaultProps}
476+
setMode={setMode}
477+
showEditColumnsButton
478+
/>,
475479
);
476480
wrapper.act(() => {
477481
wrapper.find(EditColumnsButton)!.trigger('onClick');
@@ -486,7 +490,7 @@ describe('IndexFilters', () => {
486490
<IndexFilters
487491
{...defaultProps}
488492
onEditStart={onEditStart}
489-
showEditColumns
493+
showEditColumnsButton
490494
/>,
491495
);
492496
wrapper.act(() => {

0 commit comments

Comments
 (0)