Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectPanel2: Keyboard navigation for list #3768

Merged
merged 49 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
080351c
remove sort + divider
siddharthkp Sep 20, 2023
445e150
reorder state to be more cohesive
siddharthkp Sep 20, 2023
3b36ae0
clean up suspended story
siddharthkp Sep 20, 2023
f14d727
clean up C and D
siddharthkp Sep 20, 2023
c7ed2d7
A: sort items to show initially selected ones first
siddharthkp Sep 20, 2023
6296f32
add event.preventDefault by default
siddharthkp Sep 21, 2023
7350510
add initial sorting function to stories
siddharthkp Sep 21, 2023
a5dbe92
add missing props for D with use transition
siddharthkp Sep 21, 2023
2f12c35
Replace SelectPanel.Heading with title
siddharthkp Sep 22, 2023
8413f74
add default footer
siddharthkp Sep 22, 2023
a7208c3
add minimal story
siddharthkp Sep 22, 2023
39f6779
oops, it's not possible to have query
siddharthkp Sep 22, 2023
7689c7f
Merge branch 'main' into drafts-replace-heading-with-title
siddharthkp Sep 22, 2023
7ce02ba
clean up story with tabs
siddharthkp Sep 25, 2023
796effe
Merge branch 'drafts-replace-heading-with-title' of github.com:primer…
siddharthkp Sep 25, 2023
88f27e5
Add option for external anchor
siddharthkp Sep 25, 2023
6fc2508
improve custom events story
siddharthkp Sep 25, 2023
dd17537
story: bring back filter for Filter story
siddharthkp Sep 25, 2023
d774dd8
Merge branch 'drafts-replace-heading-with-title' into drafts-external…
siddharthkp Sep 25, 2023
5dd2853
rename story
siddharthkp Sep 25, 2023
211d5ba
remove the need for SelectPanel.ActionList
siddharthkp Sep 25, 2023
4720653
add selection variable by default
siddharthkp Sep 25, 2023
ba07364
add list and item role automatically
siddharthkp Sep 25, 2023
a4197ad
oops, unused imports
siddharthkp Sep 25, 2023
1420edc
reduce scope
siddharthkp Sep 25, 2023
be44380
update ActionList snapshot
siddharthkp Sep 25, 2023
d34ca0a
Merge branch 'main' into drafts-selectpanel-simplify-actionlist
siddharthkp Sep 25, 2023
0d08c01
fix bad merge, sorry!
siddharthkp Sep 25, 2023
a7fa2d9
missed a spot!
siddharthkp Sep 25, 2023
9bf52b9
remove unrelated change
siddharthkp Sep 25, 2023
6753461
update snapshots
siddharthkp Sep 25, 2023
2457ee0
add focus zone around list
siddharthkp Sep 26, 2023
2fa432e
we don't need data-component anymore :)
siddharthkp Sep 26, 2023
a4852fe
make loading state full height
siddharthkp Sep 26, 2023
6011cc6
bring back explicit footer for suspense
siddharthkp Sep 26, 2023
40d3c57
Add warning to ActionMenu story
siddharthkp Sep 26, 2023
8e00e7f
undefined can't be a string!
siddharthkp Sep 26, 2023
02901a8
test(vrt): update snapshots
siddharthkp Sep 26, 2023
279e846
found an easier way to style
siddharthkp Sep 26, 2023
eed8da1
Merge branch 'main' into drafts-selectpanel-simplify-actionlist
siddharthkp Sep 27, 2023
f046646
Revert "test(vrt): update snapshots"
siddharthkp Sep 27, 2023
9f8cf08
Merge branch 'drafts-selectpanel-footer-fix' into drafts-selectpanel-…
siddharthkp Sep 27, 2023
d1c872b
Empty message should be out of ActionList
siddharthkp Sep 27, 2023
283f800
footer outside BOx
siddharthkp Sep 27, 2023
9fb13cd
Merge branch 'drafts-selectpanel-simplify-actionlist' into drafts-sel…
siddharthkp Sep 27, 2023
27a2e8a
arrow keys navigation is only for list items
siddharthkp Sep 27, 2023
8e04bc1
add question
siddharthkp Sep 27, 2023
b786a21
Merge branch 'main' into drafts-selectpanel-keyboard
siddharthkp Oct 2, 2023
bc929f8
Merge branch 'main' into drafts-selectpanel-keyboard
siddharthkp Oct 19, 2023
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
24 changes: 19 additions & 5 deletions src/drafts/SelectPanel2/SelectPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import {
Heading,
Box,
AnchoredOverlay,
AnchoredOverlayProps,
Tooltip,
TextInput,
AnchoredOverlayProps,
Spinner,
Text,
} from '../../../src/index'
import {ActionListContainerContext} from '../../../src/ActionList/ActionListContainerContext'
import {useSlots} from '../../hooks/useSlots'
import {useProvidedRefOrCreate} from '../../hooks'
import {useFocusZone} from '../../hooks/useFocusZone'

const SelectPanelContext = React.createContext<{
title: string
Expand Down Expand Up @@ -72,6 +73,15 @@ const SelectPanel = props => {

const [slots, childrenInBody] = useSlots(contents, {header: SelectPanelHeader, footer: SelectPanelFooter})

/* Arrow keys navigation for list items */
const {containerRef: listContainerRef} = useFocusZone(
{
bindKeys: FocusKeys.ArrowVertical | FocusKeys.HomeAndEnd | FocusKeys.PageUpDown,
focusableElementFilter: element => element.tagName === 'LI',
},
[internalOpen],
)

return (
<>
<AnchoredOverlay
Expand All @@ -83,11 +93,13 @@ const SelectPanel = props => {
onClose={onInternalClose}
width={props.width || 'medium'}
height={props.height || 'large'}
focusZoneSettings={{bindKeys: FocusKeys.Tab}}
focusZoneSettings={{
// we only want focus trap from the overlay,
// we don't want focus zone on the whole overlay because
// we have a focus zone on the list
disabled: true,
}}
>
{/* TODO: Keyboard navigation of actionlist should be arrow keys
with tabs to enter and escape
*/}
<SelectPanelContext.Provider
value={{
title: props.title,
Expand All @@ -110,6 +122,8 @@ const SelectPanel = props => {
{/* render default header as fallback */}
{slots.header || <SelectPanel.Header />}
<Box
as="div"
ref={listContainerRef as React.RefObject<HTMLDivElement>}
sx={{
flexShrink: 1,
flexGrow: 1,
Expand Down
1 change: 1 addition & 0 deletions src/drafts/SelectPanel2/work-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

## Open accessibility questions

1. Should pressing ArrowDown on SearchInput jump to first list item? Or only with Tab
1. Should the text for Submit/Save button be customisable based on the page context? So that it says something like "Assign users" or "Add labels" instead of just "Save" or "Submit". Or is optional because the context is already established?

## Answered accessibility questions
Expand Down
Loading