Skip to content

Commit

Permalink
fix: esc key dismisses listbox (#169)
Browse files Browse the repository at this point in the history
Fixes #168
  • Loading branch information
nolanlawson committed Jul 7, 2021
1 parent 17ea728 commit 13e6c12
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/picker/components/Picker/Picker.js
Expand Up @@ -625,6 +625,7 @@ function onSkinToneOptionsKeydown (event) {
return onSkinToneOptionsClick(event)
case 'Escape':
halt(event)
skinTonePickerExpanded = false
return focus('skintone-button')
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/spec/picker/Picker.test.js
Expand Up @@ -157,10 +157,11 @@ describe('Picker tests', () => {

await fireEvent.keyDown(activeElement(), { key: 'Escape', code: 'Escape' })

// listbox closes, which we observe by seeing what's focused
// listbox closes and skintone dropdown button becomes active element
await waitFor(async () => (
expect(await getAccessibleName(container, activeElement())).toEqual('Choose a skin tone (currently Default)'))
)
await waitFor(() => expect(queryAllByRole('listbox', { name: 'Skin tones' })).toHaveLength(0))
})

test('nav keyboard test', async () => {
Expand Down

0 comments on commit 13e6c12

Please sign in to comment.