From 3e18249b3a82be44421d4906b7bc2f7d6ed40285 Mon Sep 17 00:00:00 2001 From: Chloe Rice Date: Mon, 25 Sep 2023 14:33:23 -0400 Subject: [PATCH 1/3] [Page] Revert page action disabling when in IndexFilter's filter mode --- .changeset/kind-lemons-jump.md | 5 ++++ .../Page/components/Header/Header.tsx | 28 ++++--------------- 2 files changed, 10 insertions(+), 23 deletions(-) create mode 100644 .changeset/kind-lemons-jump.md diff --git a/.changeset/kind-lemons-jump.md b/.changeset/kind-lemons-jump.md new file mode 100644 index 00000000000..f865f42fb6c --- /dev/null +++ b/.changeset/kind-lemons-jump.md @@ -0,0 +1,5 @@ +--- +'@shopify/polaris': patch +--- + +Reverted disabling of `Page` `secondaryActions` when `IndexFilters` is in filter `mode` diff --git a/polaris-react/src/components/Page/components/Header/Header.tsx b/polaris-react/src/components/Page/components/Header/Header.tsx index 8fbf00182a5..2ff7e886198 100644 --- a/polaris-react/src/components/Page/components/Header/Header.tsx +++ b/polaris-react/src/components/Page/components/Header/Header.tsx @@ -26,10 +26,6 @@ import type {PaginationProps} from '../../../Pagination'; import {ActionMenu, hasGroupsWithActions} from '../../../ActionMenu'; import {isInterface} from '../../../../utilities/is-interface'; import {isReactElement} from '../../../../utilities/is-react-element'; -import { - IndexFiltersMode, - useSetIndexFiltersMode, -} from '../../../../utilities/index-filters'; import {Box} from '../../../Box'; import {HorizontalStack} from '../../../HorizontalStack'; import {useFeatures} from '../../../../utilities/features'; @@ -97,8 +93,6 @@ export function Header({ const i18n = useI18n(); const {polarisSummerEditions2023} = useFeatures(); const {isNavigationCollapsed} = useMediaQuery(); - const {mode} = useSetIndexFiltersMode(); - const disableActions = mode !== IndexFiltersMode.Default; if (additionalNavigation && process.env.NODE_ENV === 'development') { // eslint-disable-next-line no-console @@ -132,8 +126,8 @@ export function Header({ @@ -157,10 +151,7 @@ export function Header({ ); const primaryActionMarkup = primaryAction ? ( - + ) : null; let actionMenuMarkup: MaybeJSX = null; @@ -170,14 +161,8 @@ export function Header({ ) { actionMenuMarkup = ( ({ - ...secondaryAction, - disabled: disableActions || secondaryAction.disabled, - }))} - groups={actionGroups.map((actionGroup) => ({ - ...actionGroup, - disabled: disableActions || actionGroup.disabled, - }))} + actions={secondaryActions} + groups={actionGroups} rollup={isNavigationCollapsed} rollupActionsLabel={ title @@ -290,10 +275,8 @@ export function Header({ function PrimaryActionMarkup({ primaryAction, - disabled, }: { primaryAction: PrimaryAction | React.ReactNode; - disabled: boolean; }) { const {isNavigationCollapsed} = useMediaQuery(); @@ -305,7 +288,6 @@ function PrimaryActionMarkup({ shouldShowIconOnly(isNavigationCollapsed, primaryAction), { primary, - disabled: disabled || primaryAction.disabled, }, ); From 07a96590c33db3a8bdc568ab5fddef60c6f5f06a Mon Sep 17 00:00:00 2001 From: Chloe Rice Date: Mon, 25 Sep 2023 15:16:32 -0400 Subject: [PATCH 2/3] Remove related tests --- .../components/Header/tests/Header.test.tsx | 59 ------------------- 1 file changed, 59 deletions(-) diff --git a/polaris-react/src/components/Page/components/Header/tests/Header.test.tsx b/polaris-react/src/components/Page/components/Header/tests/Header.test.tsx index b69084d7ae7..f582df18a91 100644 --- a/polaris-react/src/components/Page/components/Header/tests/Header.test.tsx +++ b/polaris-react/src/components/Page/components/Header/tests/Header.test.tsx @@ -116,26 +116,6 @@ describe('
', () => { }); }); - it('renders a disabled button when a non-default IndexFiltersMode is set', () => { - const primaryAction: HeaderProps['primaryAction'] = { - content: buttonContent, - }; - - const header = mountWithApp( -
, - { - indexFilters: { - mode: IndexFiltersMode.Filtering, - }, - }, - ); - - expect(header).toContainReactComponent(Button, { - disabled: true, - children: buttonContent, - }); - }); - it('renders a `ReactNode`', () => { const PrimaryAction = () => null; @@ -174,27 +154,6 @@ describe('
', () => { hasNext: true, }); }); - - it('adds false values for hasNext and hasPrevious when a non-default IndexFiltersMode is set', () => { - const pagination = { - hasNext: true, - hasPrevious: true, - }; - - const header = mountWithApp( -
, - { - indexFilters: { - mode: IndexFiltersMode.Filtering, - }, - }, - ); - - expect(header).toContainReactComponent(Pagination, { - hasNext: false, - hasPrevious: false, - }); - }); }); describe('actionGroups', () => { @@ -222,24 +181,6 @@ describe('
', () => { groups: mockActionGroups, }); }); - - it('disables actions within the actionGroups when a non-default IndexFiltersMode is set', () => { - const wrapper = mountWithApp( -
, - { - indexFilters: { - mode: IndexFiltersMode.Filtering, - }, - }, - ); - - expect(wrapper).toContainReactComponent(ActionMenu, { - groups: mockActionGroups.map((actionGroup) => ({ - ...actionGroup, - disabled: true, - })), - }); - }); }); describe('additionalNavigation', () => { From 2e9ba9e2aa99d57974bba54fec1291837fe3999f Mon Sep 17 00:00:00 2001 From: Sophie Schneider Date: Mon, 25 Sep 2023 19:26:22 +0000 Subject: [PATCH 3/3] Remove unused import --- .../src/components/Page/components/Header/tests/Header.test.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/polaris-react/src/components/Page/components/Header/tests/Header.test.tsx b/polaris-react/src/components/Page/components/Header/tests/Header.test.tsx index f582df18a91..6eba736a8c1 100644 --- a/polaris-react/src/components/Page/components/Header/tests/Header.test.tsx +++ b/polaris-react/src/components/Page/components/Header/tests/Header.test.tsx @@ -12,7 +12,6 @@ import {Tooltip} from '../../../../Tooltip'; import type {LinkAction, MenuActionDescriptor} from '../../../../../types'; import {Header} from '../Header'; import type {HeaderProps} from '../Header'; -import {IndexFiltersMode} from '../../../../../utilities/index-filters'; describe('
', () => { const mockProps: HeaderProps = {