Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/kind-lemons-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': patch
---

Reverted disabling of `Page` `secondaryActions` when `IndexFilters` is in filter `mode`
28 changes: 5 additions & 23 deletions polaris-react/src/components/Page/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -132,8 +126,8 @@ export function Header({
<Box printHidden>
<Pagination
{...pagination}
hasPrevious={disableActions ? false : pagination.hasPrevious}
hasNext={disableActions ? false : pagination.hasNext}
hasPrevious={pagination.hasPrevious}
hasNext={pagination.hasNext}
/>
</Box>
</div>
Expand All @@ -157,10 +151,7 @@ export function Header({
);

const primaryActionMarkup = primaryAction ? (
<PrimaryActionMarkup
primaryAction={primaryAction}
disabled={disableActions}
/>
<PrimaryActionMarkup primaryAction={primaryAction} />
) : null;

let actionMenuMarkup: MaybeJSX = null;
Expand All @@ -170,14 +161,8 @@ export function Header({
) {
actionMenuMarkup = (
<ActionMenu
actions={secondaryActions.map((secondaryAction) => ({
...secondaryAction,
disabled: disableActions || secondaryAction.disabled,
}))}
groups={actionGroups.map((actionGroup) => ({
...actionGroup,
disabled: disableActions || actionGroup.disabled,
}))}
actions={secondaryActions}
groups={actionGroups}
rollup={isNavigationCollapsed}
rollupActionsLabel={
title
Expand Down Expand Up @@ -290,10 +275,8 @@ export function Header({

function PrimaryActionMarkup({
primaryAction,
disabled,
}: {
primaryAction: PrimaryAction | React.ReactNode;
disabled: boolean;
}) {
const {isNavigationCollapsed} = useMediaQuery();

Expand All @@ -305,7 +288,6 @@ function PrimaryActionMarkup({
shouldShowIconOnly(isNavigationCollapsed, primaryAction),
{
primary,
disabled: disabled || primaryAction.disabled,
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('<Header />', () => {
const mockProps: HeaderProps = {
Expand Down Expand Up @@ -116,26 +115,6 @@ describe('<Header />', () => {
});
});

it('renders a disabled button when a non-default IndexFiltersMode is set', () => {
const primaryAction: HeaderProps['primaryAction'] = {
content: buttonContent,
};

const header = mountWithApp(
<Header {...mockProps} primaryAction={primaryAction} />,
{
indexFilters: {
mode: IndexFiltersMode.Filtering,
},
},
);

expect(header).toContainReactComponent(Button, {
disabled: true,
children: buttonContent,
});
});

it('renders a `ReactNode`', () => {
const PrimaryAction = () => null;

Expand Down Expand Up @@ -174,27 +153,6 @@ describe('<Header />', () => {
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(
<Header {...mockProps} pagination={pagination} />,
{
indexFilters: {
mode: IndexFiltersMode.Filtering,
},
},
);

expect(header).toContainReactComponent(Pagination, {
hasNext: false,
hasPrevious: false,
});
});
});

describe('actionGroups', () => {
Expand Down Expand Up @@ -222,24 +180,6 @@ describe('<Header />', () => {
groups: mockActionGroups,
});
});

it('disables actions within the actionGroups when a non-default IndexFiltersMode is set', () => {
const wrapper = mountWithApp(
<Header {...mockProps} actionGroups={mockActionGroups} />,
{
indexFilters: {
mode: IndexFiltersMode.Filtering,
},
},
);

expect(wrapper).toContainReactComponent(ActionMenu, {
groups: mockActionGroups.map((actionGroup) => ({
...actionGroup,
disabled: true,
})),
});
});
});

describe('additionalNavigation', () => {
Expand Down