forked from missive/emoji-mart
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- SR & Live Region - add new componet to handle SR annoucements with delay, as focus imput interrupts the annoucements - screen reader announcement no longer announces individual emojis, but rather the count of emojis found OR no emoji found message if none are found - add aria-atomic for the aria-live region to ensure the SR reads the whole message - Navigation - disabled top navigation buttons while search input is focused. This was added because while the input is focused, the tab navigation doesn't do anything in the current implementation, and it can be misleading if not disabled. (user can still hover, and they appear as normal btns). - Search - changed the outer div to a form with role search to improve semantics - add aria-hidden on the loupe icon in the search bar - add aria-label to the search input to be able to give more context if necessary - Search Result & Default Categories - render no result message in the preview section, when preview section is not rendered. previously the no result was only shown in the preview, but since the picker already supports hiding it, we don't want to loose the visual cue of "no emojis found" - add aria-label to the outer div around the all the moji categories - add aria-labelledby for each group of emojis pointing to the section header, and add role = group chore(prettier): fix pretier fix(picker): remove unused func, and add aria-expanded to skin btn chore(pr): address pr comments
- Loading branch information
Catalin
committed
Aug 30, 2024
1 parent
8c04a32
commit 0bc77c1
Showing
5 changed files
with
107 additions
and
31 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
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
44 changes: 44 additions & 0 deletions
44
packages/emoji-mart/src/components/ScreenReaderAnnouncement/index.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,44 @@ | ||
import { useEffect, useState } from 'preact/hooks' | ||
|
||
type Level = 'assertive' | 'polite' | ||
|
||
type AnnouncementProps = { | ||
text: string | ||
level: Level | ||
delay: number | ||
timeout: number | ||
} | ||
|
||
/** | ||
* Component which will cause a screen reader to announce a message when required. | ||
*/ | ||
const ScreenReaderAnnouncement = ({ | ||
delay = 1500, | ||
level, | ||
text, | ||
timeout = 2000, | ||
}: AnnouncementProps) => { | ||
const [message, setMessage] = useState('') | ||
|
||
useEffect(() => { | ||
let timer = setTimeout(() => { | ||
setMessage(text) | ||
|
||
timer = setTimeout(() => { | ||
setMessage('') | ||
}, timeout) | ||
}, delay) | ||
|
||
return () => { | ||
clearTimeout(timer) | ||
} | ||
}, [delay, text, timeout]) | ||
|
||
return ( | ||
<div aria-live={level} className="sr-only" aria-atomic="true"> | ||
{message} | ||
</div> | ||
) | ||
} | ||
|
||
export default ScreenReaderAnnouncement |