fix: remove blur/focusout event for now (#15)

* fix: remove blur/focusout event for now

fixes #14

* test: disable test
This commit is contained in:
Nolan Lawson 2020-06-30 13:01:58 -07:00 committed by GitHub
parent 04f490a6cb
commit d0bb1fd51d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 16 deletions

View File

@ -54,7 +54,6 @@
aria-activedescendant="skintone-{activeSkinTone}"
aria-hidden={!skinTonePickerExpanded}
on:keydown={onSkinToneOptionKeydown}
on:focusout={onSkinToneOptionsBlur}
on:click={onClickSkinToneOption}
bind:this={skinToneDropdown}>
{#each skinTones as skinTone, i (skinTone)}

View File

@ -583,20 +583,6 @@ function onSkinToneOptionKeydown (event) {
}
}
// eslint-disable-next-line no-unused-vars
async function onSkinToneOptionsBlur () {
// On blur outside of the skintone options, collapse the skintone picker.
// Except if focus is just moving to another skintone option, e.g. pressing up/down to change focus
// I would use relatedTarget here, but iOS Safari seems to have a bug where it does not figure out
// the relatedTarget correctly, so I delay with rAF instead
await new Promise(resolve => requestAnimationFrame(resolve))
const { activeElement } = rootElement.getRootNode()
if (!activeElement || !activeElement.classList.contains('skintone-option')) {
skinTonePickerExpanded = false
}
}
export {
locale,
dataSource,

View File

@ -313,7 +313,8 @@ describe('Picker tests', () => {
await waitFor(() => expect(emoji && emoji.name === 'donkey'))
}, 5000)
test('Closes skintone picker when blurred', async () => {
// TODO: re-enable this behavior. See https://github.com/nolanlawson/emoji-picker-element/issues/14
test.skip('Closes skintone picker when blurred', async () => {
fireEvent.click(getByRole('button', { name: /Choose a skin tone/ }))
await waitFor(() => expect(getByRole('listbox', { name: 'Skin tones' })).toBeVisible())
// Simulating a focusout event is hard, have to both focus and blur