{categoryName}
@@ -1039,6 +1066,8 @@ export default class Picker extends Component {
return null
}
+ const ariaSkinToneShown = this.state.showSkins ? 'true' : 'false'
+
return (
- {contents}
-
- )
- }
-
renderSkins() {
const skinToneButton = this.refs.skinToneButton.current
const skinToneButtonRect = skinToneButton.getBoundingClientRect()
@@ -1117,6 +1131,7 @@ export default class Picker extends Component {
class="menu hidden"
data-position={position.top ? 'top' : 'bottom'}
style={position}
+ id="skin-tone-options"
>
{[...Array(6).keys()].map((i) => {
const skin = i + 1
@@ -1166,8 +1181,9 @@ export default class Picker extends Component {
const lineWidth = this.props.perLine * this.props.emojiButtonSize
return (
-
{this.props.searchPosition == 'static' && this.renderSearch()}
{this.renderSearchResults()}
@@ -1202,8 +1218,11 @@ export default class Picker extends Component {
{this.props.navPosition == 'bottom' && this.renderNav()}
{this.props.previewPosition == 'bottom' && this.renderPreview()}
{this.state.showSkins && this.renderSkins()}
- {this.renderLiveRegion()}
-
+
+
)
}
}
diff --git a/packages/emoji-mart/src/components/Picker/PickerStyles.scss b/packages/emoji-mart/src/components/Picker/PickerStyles.scss
index e68b6613..70c2b497 100644
--- a/packages/emoji-mart/src/components/Picker/PickerStyles.scss
+++ b/packages/emoji-mart/src/components/Picker/PickerStyles.scss
@@ -127,12 +127,15 @@
}
.sr-only {
- position: absolute;
- left: -10000px;
- top: auto;
- width: 1px;
+ border: 0;
+ clip: rect(0, 0, 0, 0);
height: 1px;
+ margin: -1px;
overflow: hidden;
+ padding: 0;
+ position: absolute;
+ white-space: nowrap;
+ width: 1px;
}
a {
@@ -293,6 +296,11 @@ button {
&:hover { color: var(--color-a) }
}
+ button:disabled {
+ color: var(--color-c);
+ cursor: not-allowed;
+ }
+
svg, img {
width: var(--category-icon-size);
height: var(--category-icon-size);
diff --git a/packages/emoji-mart/src/components/ScreenReaderAnnouncement/index.tsx b/packages/emoji-mart/src/components/ScreenReaderAnnouncement/index.tsx
new file mode 100644
index 00000000..1d4f3070
--- /dev/null
+++ b/packages/emoji-mart/src/components/ScreenReaderAnnouncement/index.tsx
@@ -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 (
+
+ {message}
+
+ )
+}
+
+export default ScreenReaderAnnouncement