Skip to content

Commit c9b5475

Browse files
authored
[IndexFilters] Remove IndexFiltersManager, reinstate useSetIndexFiltersMode (#10745)
### WHY are these changes introduced? We recently removed the logic to disable page actions when in filtering mode, so the work to extract the filtering state into global context is no longer required, and should be cleaned up. This PR reverts things to how they were before https://github.com/Shopify/polaris/pull/10490/files merged. ### WHAT is this pull request doing? ### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) ### 🎩 checklist - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [x] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [x] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
1 parent 937c485 commit c9b5475

File tree

20 files changed

+35
-340
lines changed

20 files changed

+35
-340
lines changed

.changeset/spicy-pugs-begin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': major
3+
---
4+
5+
[IndexFilters] Remove IndexFiltersManager in AppProvider

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
ScrollLockManager,
1717
ScrollLockManagerContext,
1818
} from '../../utilities/scroll-lock-manager';
19-
import {IndexFiltersManager} from '../../utilities/index-filters';
2019
import {
2120
StickyManager,
2221
StickyManagerContext,
@@ -168,7 +167,7 @@ export class AppProvider extends Component<AppProviderProps, State> {
168167
<PortalsManager>
169168
<FocusManager>
170169
<EphemeralPresenceManager>
171-
<IndexFiltersManager>{children}</IndexFiltersManager>
170+
{children}
172171
</EphemeralPresenceManager>
173172
</FocusManager>
174173
</PortalsManager>

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

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,107 +1122,3 @@ export function WithQueryFieldAndFiltersHidden() {
11221122
</Card>
11231123
);
11241124
}
1125-
1126-
export function WrappedInAPage() {
1127-
return (
1128-
<Page
1129-
backAction={{content: 'Products', url: '#'}}
1130-
title="3/4 inch Leather pet collar"
1131-
titleMetadata={<Badge status="success">Paid</Badge>}
1132-
subtitle="Perfect for any pet"
1133-
compactTitle
1134-
primaryAction={{content: 'Save'}}
1135-
secondaryActions={[
1136-
{
1137-
content: 'Delete',
1138-
destructive: true,
1139-
icon: DeleteMinor,
1140-
accessibilityLabel: 'Delete action label',
1141-
onAction: () => console.log('Delete action'),
1142-
},
1143-
{
1144-
content: 'View on your store',
1145-
icon: ViewMinor,
1146-
onAction: () => console.log('View on your store action'),
1147-
},
1148-
]}
1149-
actionGroups={[
1150-
{
1151-
title: 'Promote',
1152-
icon: MobileVerticalDotsMajor,
1153-
actions: [
1154-
{
1155-
content: 'Share on Facebook',
1156-
accessibilityLabel: 'Individual action label',
1157-
onAction: () => console.log('Share on Facebook action'),
1158-
},
1159-
],
1160-
},
1161-
]}
1162-
pagination={{
1163-
hasPrevious: true,
1164-
hasNext: true,
1165-
}}
1166-
>
1167-
<BasicExample />
1168-
</Page>
1169-
);
1170-
}
1171-
1172-
export function WrappedInAPageWithCustomActions() {
1173-
const {mode} = useSetIndexFiltersMode();
1174-
const shouldDisableAction = mode !== IndexFiltersMode.Default;
1175-
return (
1176-
<Page
1177-
backAction={{content: 'Products', url: '#'}}
1178-
title="3/4 inch Leather pet collar"
1179-
titleMetadata={<Badge status="success">Paid</Badge>}
1180-
subtitle="Perfect for any pet"
1181-
compactTitle
1182-
primaryAction={
1183-
<Button
1184-
primary
1185-
disabled={shouldDisableAction}
1186-
connectedDisclosure={{
1187-
disabled: shouldDisableAction,
1188-
accessibilityLabel: 'Other save actions',
1189-
actions: [{content: 'Save as new'}],
1190-
}}
1191-
>
1192-
Save
1193-
</Button>
1194-
}
1195-
secondaryActions={
1196-
<Button
1197-
disabled={shouldDisableAction}
1198-
connectedDisclosure={{
1199-
disabled: shouldDisableAction,
1200-
accessibilityLabel: 'Other save actions',
1201-
actions: [{content: 'Rename'}],
1202-
}}
1203-
>
1204-
Update
1205-
</Button>
1206-
}
1207-
actionGroups={[
1208-
{
1209-
title: 'Promote',
1210-
icon: MobileVerticalDotsMajor,
1211-
actions: [
1212-
{
1213-
content: 'Share on Facebook',
1214-
accessibilityLabel: 'Individual action label',
1215-
onAction: () => console.log('Share on Facebook action'),
1216-
},
1217-
],
1218-
},
1219-
]}
1220-
pagination={{
1221-
hasPrevious: true,
1222-
hasNext: true,
1223-
}}
1224-
>
1225-
<BasicExample />
1226-
</Page>
1227-
);
1228-
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type {FiltersProps} from '../Filters';
1313
import {Tabs} from '../Tabs';
1414
import type {TabsProps} from '../Tabs';
1515
import {useBreakpoints} from '../../utilities/breakpoints';
16-
import {IndexFiltersMode} from '../../utilities/index-filters';
1716

1817
import {useIsSticky} from './hooks';
1918
import {
@@ -27,6 +26,7 @@ import type {
2726
IndexFiltersCancelAction,
2827
SortButtonChoice,
2928
} from './types';
29+
import {IndexFiltersMode} from './types';
3030
import styles from './IndexFilters.scss';
3131

3232
const DEFAULT_IGNORED_TAGS = ['INPUT', 'SELECT', 'TEXTAREA'];
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export * from './useSetIndexFiltersMode';
12
export * from './useIsSticky';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import {intersectionObserver} from '@shopify/jest-dom-mocks';
33
import {mountWithApp} from 'tests/utilities';
44

5-
import {IndexFiltersMode} from '../../../../../utilities/index-filters';
5+
import {IndexFiltersMode} from '../../../types';
66
import {useIsSticky} from '..';
77

88
interface Props {

polaris-react/src/components/IndexFilters/hooks/useIsSticky/useIsSticky.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {useEffect, useRef, useState} from 'react';
22
import type {RefObject} from 'react';
33

44
import {debounce} from '../../../../utilities/debounce';
5-
import type {IndexFiltersMode} from '../../../../utilities/index-filters';
5+
import type {IndexFiltersMode} from '../../types';
66

77
const DEBOUNCE_PERIOD = 250;
88

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './useSetIndexFiltersMode';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {useState} from 'react';
2+
3+
import {IndexFiltersMode} from '../../types';
4+
5+
export function useSetIndexFiltersMode(
6+
defaultMode: IndexFiltersMode = IndexFiltersMode.Default,
7+
) {
8+
const [mode, setMode] = useState<IndexFiltersMode>(defaultMode);
9+
10+
return {mode, setMode};
11+
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import {matchMedia} from '@shopify/jest-dom-mocks';
55

66
import {Tabs} from '../../Tabs';
77
import {Filters} from '../../Filters';
8-
import {IndexFilters} from '..';
9-
import {IndexFiltersMode} from '../../../utilities/index-filters';
8+
import {IndexFilters, IndexFiltersMode} from '..';
109
import type {IndexFiltersProps} from '../IndexFilters';
1110
import {SearchFilterButton, SortButton, UpdateButtons} from '../components';
1211

0 commit comments

Comments
 (0)