diff --git a/packages/emoji-mart-data/i18n/en.json b/packages/emoji-mart-data/i18n/en.json index 68116c5b..2444f8bf 100644 --- a/packages/emoji-mart-data/i18n/en.json +++ b/packages/emoji-mart-data/i18n/en.json @@ -2,6 +2,10 @@ "search": "Search", "search_no_results_1": "Oh no!", "search_no_results_2": "That emoji couldn’t be found", + "emojis_found_plural": "emojis found", + "emoji_found_singular": "emoji found", + "search_input_aria_label": "Search emojis", + "available_emojis": "Available emojis", "pick": "Pick an emoji…", "add_custom": "Add custom emoji", "categories": { diff --git a/packages/emoji-mart/src/components/Navigation/Navigation.tsx b/packages/emoji-mart/src/components/Navigation/Navigation.tsx index 194432be..7dc8ef3c 100644 --- a/packages/emoji-mart/src/components/Navigation/Navigation.tsx +++ b/packages/emoji-mart/src/components/Navigation/Navigation.tsx @@ -111,6 +111,7 @@ export default class Navigation extends PureComponent { type="button" class="flex flex-grow flex-center" role="tab" + disabled={this.props.disabled} tabIndex={selected ? 0 : -1} onMouseDown={(e) => e.preventDefault()} onClick={() => { diff --git a/packages/emoji-mart/src/components/Picker/Picker.tsx b/packages/emoji-mart/src/components/Picker/Picker.tsx index 0550a8b9..8ba204df 100644 --- a/packages/emoji-mart/src/components/Picker/Picker.tsx +++ b/packages/emoji-mart/src/components/Picker/Picker.tsx @@ -10,6 +10,7 @@ import type { Category } from '@slidoapp/emoji-mart-data' import { Emoji } from '../Emoji' import { PureInlineComponent } from '../HOCs' import { Navigation } from '../Navigation' +import ScreenReaderAnnouncement from '../ScreenReaderAnnouncement' const Performance = { rowsPerRender: 10, @@ -707,6 +708,7 @@ export default class Picker extends Component { theme={this.state.theme} dir={this.dir} unfocused={!!this.state.searchResults} + disabled={!!this.state.searchResults} position={this.props.navPosition} onClick={this.handleCategoryClick} /> @@ -856,6 +858,20 @@ export default class Picker extends Component { ) } + getResultMessage() { + const { searchResults } = this.state + if (searchResults === undefined || searchResults === null) return '' + + if (searchResults.length <= 0) { + return I18n.search_no_results_2 + } else { + let count = searchResults.flat().length + let translation = + count === 1 ? I18n.emoji_found_singular : I18n.emojis_found_plural + return [count, translation].join(' ') + } + } + renderSearch() { const renderSkinTone = this.props.previewPosition == 'none' || @@ -873,9 +889,12 @@ export default class Picker extends Component { onClick={this.handleSearchClick} onInput={this.handleSearchInput} onKeyDown={this.handleEmojisKeyDown} - autoComplete="off" - > - {Icons.search.loupe} + aria-label={I18n.search_input_aria_label} + autocomplete="off" + /> + {this.state.searchResults && (