-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SelectPanel: Update SelectPanel to use modern ActionList (#4794)
* super wip * just use the actionlist component and revert the type updates * Update packages/react/src/FilteredActionList/FilteredActionList.tsx * Some more progress * revert the type changes and cast it :/ * clean * wip * wip wip * add stories * fix linting * add tests for groups * Map groups * Update story names for e2e tests * oops remove unintended file * update story name * same - update story name * disable animations * test(vrt): update snapshots * Update tests since new action list has different semantics for group headings * logging * pass the rest * extract children and use before text * remove logging * test(vrt): update snapshots * add active styles to ActionList * rename component name to be clearer * remove variant full from examples * tiny clean up * fix showItemDividers * another tiny cleanup * pull MappedActionListItem to make it stable * test(vrt): update snapshots * show active styles only when used with keyboard * backward compat: expose id as data-id * update snapshots * add story for long strings * fishing for errors * backward compatibility for renderItem * remove todo now * add a feature flag * clean up dual filter list setup * run jests test with both states of feature flags * refactor snapshot tests with scenarios * remove feature flag for main * test(vrt): update snapshots * add feature flag to e2e matrix * test(vrt): update snapshots * backward compat: allow groupMetadata to be empty array * sigh newline * Create sour-cooks-dress.md * copy SelectPanel snapshots from main * remove unrelated changes in this PR * test(vrt): update snapshots * set active styles for both active-descendant types * test(vrt): update snapshots --------- Co-authored-by: broccolinisoup <broccolinisoup@users.noreply.github.com> Co-authored-by: Siddharth Kshetrapal <siddharthkp@github.com> Co-authored-by: siddharthkp <siddharthkp@users.noreply.github.com>
- Loading branch information
1 parent
c282642
commit 5f996c6
Showing
130 changed files
with
1,016 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/react": patch | ||
--- | ||
|
||
SelectPanel: Update SelectPanel to use modern ActionList behind a feature flag `primer_react_select_panel_with_modern_action_list` |
Binary file added
BIN
+38.3 KB
.../SelectPanel-Above-Tall-Body-dark-colorblind-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.2 KB
...hots/SelectPanel-Above-Tall-Body-dark-dimmed-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.8 KB
...lectPanel-Above-Tall-Body-dark-high-contrast-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.3 KB
...s-snapshots/SelectPanel-Above-Tall-Body-dark-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.3 KB
.../SelectPanel-Above-Tall-Body-dark-tritanopia-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.5 KB
...SelectPanel-Above-Tall-Body-light-colorblind-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.5 KB
...ectPanel-Above-Tall-Body-light-high-contrast-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.5 KB
...-snapshots/SelectPanel-Above-Tall-Body-light-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.5 KB
...SelectPanel-Above-Tall-Body-light-tritanopia-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.6 KB
...napshots/SelectPanel-Default-dark-colorblind-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.7 KB
...ts-snapshots/SelectPanel-Default-dark-dimmed-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+34.6 KB
...shots/SelectPanel-Default-dark-high-contrast-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.6 KB
...l.test.ts-snapshots/SelectPanel-Default-dark-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.6 KB
...napshots/SelectPanel-Default-dark-tritanopia-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.6 KB
...apshots/SelectPanel-Default-light-colorblind-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.7 KB
...hots/SelectPanel-Default-light-high-contrast-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.6 KB
....test.ts-snapshots/SelectPanel-Default-light-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.6 KB
...apshots/SelectPanel-Default-light-tritanopia-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.7 KB
.../SelectPanel-External-Anchor-dark-colorblind-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+31.2 KB
...hots/SelectPanel-External-Anchor-dark-dimmed-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+28.8 KB
...lectPanel-External-Anchor-dark-high-contrast-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.7 KB
...s-snapshots/SelectPanel-External-Anchor-dark-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.7 KB
.../SelectPanel-External-Anchor-dark-tritanopia-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30 KB
...SelectPanel-External-Anchor-light-colorblind-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.4 KB
...ectPanel-External-Anchor-light-high-contrast-modern-action-list--true-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30 KB
...-snapshots/SelectPanel-External-Anchor-light-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30 KB
...SelectPanel-External-Anchor-light-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.5 KB
...itial-with-Overflowing-Items-dark-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.9 KB
...t-Initial-with-Overflowing-Items-dark-dimmed-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+28.8 KB
...al-with-Overflowing-Items-dark-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.5 KB
...l-Height-Initial-with-Overflowing-Items-dark-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.5 KB
...itial-with-Overflowing-Items-dark-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.8 KB
...tial-with-Overflowing-Items-light-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.7 KB
...l-with-Overflowing-Items-light-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.8 KB
...-Height-Initial-with-Overflowing-Items-light-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.8 KB
...tial-with-Overflowing-Items-light-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+25 KB
...derflowing-Items-After-Fetch-dark-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+26.3 KB
...h-Underflowing-Items-After-Fetch-dark-dimmed-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+24.2 KB
...flowing-Items-After-Fetch-dark-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+25 KB
...ial-with-Underflowing-Items-After-Fetch-dark-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+25 KB
...derflowing-Items-After-Fetch-dark-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+25.2 KB
...erflowing-Items-After-Fetch-light-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+25.1 KB
...lowing-Items-After-Fetch-light-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+25.2 KB
...al-with-Underflowing-Items-After-Fetch-light-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+25.2 KB
...erflowing-Items-After-Fetch-light-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+27.1 KB
...tial-with-Underflowing-Items-dark-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+28.4 KB
...-Initial-with-Underflowing-Items-dark-dimmed-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+26.4 KB
...l-with-Underflowing-Items-dark-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+27.1 KB
...-Height-Initial-with-Underflowing-Items-dark-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+27.1 KB
...tial-with-Underflowing-Items-dark-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+27.4 KB
...ial-with-Underflowing-Items-light-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+27.3 KB
...-with-Underflowing-Items-light-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+27.4 KB
...Height-Initial-with-Underflowing-Items-light-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+27.4 KB
...ial-with-Underflowing-Items-light-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+33 KB
...eight-Variantions-and-Scroll-dark-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+34.5 KB
...el-Height-Variantions-and-Scroll-dark-dimmed-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+32.3 KB
...ht-Variantions-and-Scroll-dark-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+33 KB
...lectPanel-Height-Variantions-and-Scroll-dark-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+33 KB
...eight-Variantions-and-Scroll-dark-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+33 KB
...ight-Variantions-and-Scroll-light-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+33.1 KB
...t-Variantions-and-Scroll-light-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+33 KB
...ectPanel-Height-Variantions-and-Scroll-light-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+33 KB
...ight-Variantions-and-Scroll-light-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.5 KB
...ts/SelectPanel-Single-Select-dark-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.9 KB
...pshots/SelectPanel-Single-Select-dark-dimmed-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+28.8 KB
...SelectPanel-Single-Select-dark-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.5 KB
....ts-snapshots/SelectPanel-Single-Select-dark-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.5 KB
...ts/SelectPanel-Single-Select-dark-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.8 KB
...s/SelectPanel-Single-Select-light-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.7 KB
...electPanel-Single-Select-light-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.8 KB
...ts-snapshots/SelectPanel-Single-Select-light-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.8 KB
...s/SelectPanel-Single-Select-light-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+32.3 KB
...hots/SelectPanel-With-Footer-dark-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+33.5 KB
...napshots/SelectPanel-With-Footer-dark-dimmed-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+31.6 KB
...s/SelectPanel-With-Footer-dark-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+32.3 KB
...st.ts-snapshots/SelectPanel-With-Footer-dark-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+32.3 KB
...hots/SelectPanel-With-Footer-dark-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+32.5 KB
...ots/SelectPanel-With-Footer-light-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+32.4 KB
.../SelectPanel-With-Footer-light-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+32.5 KB
...t.ts-snapshots/SelectPanel-With-Footer-light-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+32.5 KB
...ots/SelectPanel-With-Footer-light-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+44.9 KB
...hots/SelectPanel-With-Groups-dark-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+45.7 KB
...napshots/SelectPanel-With-Groups-dark-dimmed-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+44.4 KB
...s/SelectPanel-With-Groups-dark-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+44.9 KB
...st.ts-snapshots/SelectPanel-With-Groups-dark-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+44.9 KB
...hots/SelectPanel-With-Groups-dark-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+45.6 KB
...ots/SelectPanel-With-Groups-light-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+45.8 KB
.../SelectPanel-With-Groups-light-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+45.6 KB
...t.ts-snapshots/SelectPanel-With-Groups-light-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+45.6 KB
...ots/SelectPanel-With-Groups-light-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.8 KB
...lectPanel-With-Item-Dividers-dark-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+31.6 KB
...s/SelectPanel-With-Item-Dividers-dark-dimmed-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30 KB
...tPanel-With-Item-Dividers-dark-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.8 KB
...napshots/SelectPanel-With-Item-Dividers-dark-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.8 KB
...lectPanel-With-Item-Dividers-dark-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.8 KB
...ectPanel-With-Item-Dividers-light-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.9 KB
...Panel-With-Item-Dividers-light-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.8 KB
...apshots/SelectPanel-With-Item-Dividers-light-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.8 KB
...ectPanel-With-Item-Dividers-light-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.5 KB
...anel-With-Placeholder-Select-dark-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+31.5 KB
...ectPanel-With-Placeholder-Select-dark-dimmed-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.8 KB
...l-With-Placeholder-Select-dark-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.5 KB
...ots/SelectPanel-With-Placeholder-Select-dark-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.5 KB
...anel-With-Placeholder-Select-dark-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.6 KB
...nel-With-Placeholder-Select-light-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.7 KB
...-With-Placeholder-Select-light-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.6 KB
...ts/SelectPanel-With-Placeholder-Select-light-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.6 KB
...nel-With-Placeholder-Select-light-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.7 KB
...Placeholder-for-Search-Input-dark-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+31.5 KB
...ith-Placeholder-for-Search-Input-dark-dimmed-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.9 KB
...ceholder-for-Search-Input-dark-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.7 KB
...Panel-With-Placeholder-for-Search-Input-dark-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.7 KB
...Placeholder-for-Search-Input-dark-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.7 KB
...laceholder-for-Search-Input-light-colorblind-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.8 KB
...eholder-for-Search-Input-light-high-contrast-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.7 KB
...anel-With-Placeholder-for-Search-Input-light-modern-action-list--true-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.7 KB
...laceholder-for-Search-Input-light-tritanopia-modern-action-list--true-linux.png
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/react/src/FilteredActionList/FilteredActionListEntry.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
import type {FilteredActionListProps} from './FilteredActionListWithDeprecatedActionList' | ||
import {FilteredActionList as WithDeprecatedActionList} from './FilteredActionListWithDeprecatedActionList' | ||
import {FilteredActionList as WithStableActionList} from './FilteredActionListWithModernActionList' | ||
import {useFeatureFlag} from '../FeatureFlags' | ||
|
||
export function FilteredActionList(props: FilteredActionListProps): JSX.Element { | ||
const enabled = useFeatureFlag('primer_react_select_panel_with_modern_action_list') | ||
|
||
if (enabled) return <WithStableActionList {...props} /> | ||
else return <WithDeprecatedActionList {...props} /> | ||
} | ||
|
||
FilteredActionList.displayName = 'FilteredActionList' | ||
|
||
export type {FilteredActionListProps} |
File renamed without changes.
233 changes: 233 additions & 0 deletions
233
packages/react/src/FilteredActionList/FilteredActionListWithModernActionList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
import type {ScrollIntoViewOptions} from '@primer/behaviors' | ||
import {scrollIntoView} from '@primer/behaviors' | ||
import type {KeyboardEventHandler} from 'react' | ||
import React, {useCallback, useEffect, useRef} from 'react' | ||
import styled from 'styled-components' | ||
import Box from '../Box' | ||
import Spinner from '../Spinner' | ||
import type {TextInputProps} from '../TextInput' | ||
import TextInput from '../TextInput' | ||
import {get} from '../constants' | ||
import {ActionList} from '../ActionList' | ||
import type {GroupedListProps, ListPropsBase, ItemInput} from '../SelectPanel/types' | ||
import {useFocusZone} from '../hooks/useFocusZone' | ||
import {useId} from '../hooks/useId' | ||
import {useProvidedRefOrCreate} from '../hooks/useProvidedRefOrCreate' | ||
import {useProvidedStateOrCreate} from '../hooks/useProvidedStateOrCreate' | ||
import useScrollFlash from '../hooks/useScrollFlash' | ||
import {VisuallyHidden} from '../internal/components/VisuallyHidden' | ||
import type {SxProp} from '../sx' | ||
|
||
import {isValidElementType} from 'react-is' | ||
import type {RenderItemFn} from '../deprecated/ActionList/List' | ||
|
||
const menuScrollMargins: ScrollIntoViewOptions = {startMargin: 0, endMargin: 8} | ||
|
||
export interface FilteredActionListProps | ||
extends Partial<Omit<GroupedListProps, keyof ListPropsBase>>, | ||
ListPropsBase, | ||
SxProp { | ||
loading?: boolean | ||
placeholderText?: string | ||
filterValue?: string | ||
onFilterChange: (value: string, e: React.ChangeEvent<HTMLInputElement>) => void | ||
textInputProps?: Partial<Omit<TextInputProps, 'onChange'>> | ||
inputRef?: React.RefObject<HTMLInputElement> | ||
} | ||
|
||
const StyledHeader = styled.div` | ||
box-shadow: 0 1px 0 ${get('colors.border.default')}; | ||
z-index: 1; | ||
` | ||
|
||
export function FilteredActionList({ | ||
loading = false, | ||
placeholderText, | ||
filterValue: externalFilterValue, | ||
onFilterChange, | ||
items, | ||
textInputProps, | ||
inputRef: providedInputRef, | ||
sx, | ||
groupMetadata, | ||
showItemDividers, | ||
...listProps | ||
}: FilteredActionListProps): JSX.Element { | ||
const [filterValue, setInternalFilterValue] = useProvidedStateOrCreate(externalFilterValue, undefined, '') | ||
const onInputChange = useCallback( | ||
(e: React.ChangeEvent<HTMLInputElement>) => { | ||
const value = e.target.value | ||
onFilterChange(value, e) | ||
setInternalFilterValue(value) | ||
}, | ||
[onFilterChange, setInternalFilterValue], | ||
) | ||
|
||
const scrollContainerRef = useRef<HTMLDivElement>(null) | ||
const listContainerRef = useRef<HTMLUListElement>(null) | ||
const inputRef = useProvidedRefOrCreate<HTMLInputElement>(providedInputRef) | ||
const activeDescendantRef = useRef<HTMLElement>() | ||
const listId = useId() | ||
const inputDescriptionTextId = useId() | ||
const onInputKeyPress: KeyboardEventHandler = useCallback( | ||
event => { | ||
if (event.key === 'Enter' && activeDescendantRef.current) { | ||
event.preventDefault() | ||
event.nativeEvent.stopImmediatePropagation() | ||
|
||
// Forward Enter key press to active descendant so that item gets activated | ||
const activeDescendantEvent = new KeyboardEvent(event.type, event.nativeEvent) | ||
activeDescendantRef.current.dispatchEvent(activeDescendantEvent) | ||
} | ||
}, | ||
[activeDescendantRef], | ||
) | ||
|
||
useFocusZone( | ||
{ | ||
containerRef: listContainerRef, | ||
focusOutBehavior: 'wrap', | ||
focusableElementFilter: element => { | ||
return !(element instanceof HTMLInputElement) | ||
}, | ||
activeDescendantFocus: inputRef, | ||
onActiveDescendantChanged: (current, previous, directlyActivated) => { | ||
activeDescendantRef.current = current | ||
|
||
if (current && scrollContainerRef.current && directlyActivated) { | ||
scrollIntoView(current, scrollContainerRef.current, menuScrollMargins) | ||
} | ||
}, | ||
}, | ||
[ | ||
// List ref isn't set while loading. Need to re-bind focus zone when it changes | ||
loading, | ||
], | ||
) | ||
|
||
useEffect(() => { | ||
// if items changed, we want to instantly move active descendant into view | ||
if (activeDescendantRef.current && scrollContainerRef.current) { | ||
scrollIntoView(activeDescendantRef.current, scrollContainerRef.current, {...menuScrollMargins, behavior: 'auto'}) | ||
} | ||
}, [items]) | ||
|
||
useScrollFlash(scrollContainerRef) | ||
|
||
function getItemListForEachGroup(groupId: string) { | ||
const itemsInGroup = [] | ||
for (const item of items) { | ||
// Look up the group associated with the current item. | ||
if (item.groupId === groupId) { | ||
itemsInGroup.push(item) | ||
} | ||
} | ||
return itemsInGroup | ||
} | ||
|
||
return ( | ||
<Box display="flex" flexDirection="column" overflow="hidden" sx={sx}> | ||
<StyledHeader> | ||
<TextInput | ||
ref={inputRef} | ||
block | ||
width="auto" | ||
color="fg.default" | ||
value={filterValue} | ||
onChange={onInputChange} | ||
onKeyPress={onInputKeyPress} | ||
placeholder={placeholderText} | ||
aria-label={placeholderText} | ||
aria-controls={listId} | ||
aria-describedby={inputDescriptionTextId} | ||
{...textInputProps} | ||
/> | ||
</StyledHeader> | ||
<VisuallyHidden id={inputDescriptionTextId}>Items will be filtered as you type</VisuallyHidden> | ||
<Box ref={scrollContainerRef} overflow="auto"> | ||
{loading ? ( | ||
<Box width="100%" display="flex" flexDirection="row" justifyContent="center" pt={6} pb={7}> | ||
<Spinner /> | ||
</Box> | ||
) : ( | ||
<ActionList ref={listContainerRef} showDividers={showItemDividers} {...listProps} role="listbox" id={listId}> | ||
{groupMetadata?.length | ||
? groupMetadata.map((group, index) => { | ||
return ( | ||
<ActionList.Group key={index}> | ||
<ActionList.GroupHeading variant={group.header?.variant ? group.header.variant : undefined}> | ||
{group.header?.title ? group.header.title : `Group ${group.groupId}`} | ||
</ActionList.GroupHeading> | ||
{getItemListForEachGroup(group.groupId).map((item, index) => { | ||
return <MappedActionListItem key={index} {...item} renderItem={listProps.renderItem} /> | ||
})} | ||
</ActionList.Group> | ||
) | ||
}) | ||
: items.map((item, index) => { | ||
return <MappedActionListItem key={index} {...item} renderItem={listProps.renderItem} /> | ||
})} | ||
</ActionList> | ||
)} | ||
</Box> | ||
</Box> | ||
) | ||
} | ||
|
||
function MappedActionListItem(item: ItemInput & {renderItem?: RenderItemFn}) { | ||
// keep backward compatibility for renderItem | ||
// escape hatch for custom Item rendering | ||
if (typeof item.renderItem === 'function') return item.renderItem(item) | ||
|
||
const { | ||
id, | ||
description, | ||
descriptionVariant, | ||
text, | ||
trailingVisual: TrailingVisual, | ||
leadingVisual: LeadingVisual, | ||
trailingText, | ||
trailingIcon: TrailingIcon, | ||
onAction, | ||
children, | ||
...rest | ||
} = item | ||
|
||
return ( | ||
<ActionList.Item | ||
role="option" | ||
// @ts-ignore - for now | ||
onSelect={(e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => { | ||
if (typeof onAction === 'function') | ||
onAction(item, e as React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) | ||
}} | ||
data-id={id} | ||
{...rest} | ||
> | ||
{LeadingVisual ? ( | ||
<ActionList.LeadingVisual> | ||
<LeadingVisual /> | ||
</ActionList.LeadingVisual> | ||
) : null} | ||
{children} | ||
{text} | ||
{description ? <ActionList.Description variant={descriptionVariant}>{description}</ActionList.Description> : null} | ||
{TrailingVisual ? ( | ||
<ActionList.TrailingVisual> | ||
{typeof TrailingVisual !== 'string' && isValidElementType(TrailingVisual) ? ( | ||
<TrailingVisual /> | ||
) : ( | ||
TrailingVisual | ||
)} | ||
</ActionList.TrailingVisual> | ||
) : TrailingIcon || trailingText ? ( | ||
<ActionList.TrailingVisual> | ||
{trailingText} | ||
{TrailingIcon && <TrailingIcon />} | ||
</ActionList.TrailingVisual> | ||
) : null} | ||
</ActionList.Item> | ||
) | ||
} | ||
|
||
FilteredActionList.displayName = 'FilteredActionList' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export {FilteredActionList} from './FilteredActionList' | ||
export type {FilteredActionListProps} from './FilteredActionList' | ||
export {FilteredActionList} from './FilteredActionListEntry' | ||
export type {FilteredActionListProps} from './FilteredActionListEntry' |
Oops, something went wrong.