Skip to content

Commit ec7ee75

Browse files
committed
[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 5ffc826 commit ec7ee75

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

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 {
@@ -28,6 +27,7 @@ import type {
2827
IndexFiltersCancelAction,
2928
SortButtonChoice,
3029
} from './types';
30+
import {IndexFiltersMode} from './types';
3131
import styles from './IndexFilters.scss';
3232

3333
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 {
1211
SearchFilterButton,

0 commit comments

Comments
 (0)