diff --git a/README.md b/README.md index 0087e4c..9868d94 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ import { Picker } from 'emoji-mart' #### I18n ```js search: 'Search', +clear: 'Clear', // Accessible label on "clear" button notfound: 'No Emoji Found', skintext: 'Choose your default skin tone', categories: { diff --git a/css/emoji-mart.css b/css/emoji-mart.css index 12daf72..7c560ec 100644 --- a/css/emoji-mart.css +++ b/css/emoji-mart.css @@ -102,12 +102,22 @@ outline: 0; } +.emoji-mart-search input, +.emoji-mart-search input::-webkit-search-decoration, +.emoji-mart-search input::-webkit-search-cancel-button, +.emoji-mart-search input::-webkit-search-results-button, +.emoji-mart-search input::-webkit-search-results-decoration { + /* remove webkit/blink styles for + * via https://stackoverflow.com/a/9422689 */ + -webkit-appearance: none; +} + .emoji-mart-search-icon { position: absolute; - top: 9px; - right: 16px; + top: 7px; + right: 11px; z-index: 2; - padding: 0; + padding: 2px 5px 1px; border: none; background: none; } @@ -369,3 +379,17 @@ .emoji-mart-skin-tone-4 { background-color: #bf8f68 } .emoji-mart-skin-tone-5 { background-color: #9b643d } .emoji-mart-skin-tone-6 { background-color: #594539 } + +/* For screenreaders only, via https://stackoverflow.com/a/19758620 */ +.emoji-mart-sr-only { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + border: 0; +} + + diff --git a/src/components/picker/nimble-picker.js b/src/components/picker/nimble-picker.js index 1b8c120..bcbf100 100644 --- a/src/components/picker/nimble-picker.js +++ b/src/components/picker/nimble-picker.js @@ -18,6 +18,7 @@ import { PickerDefaultProps } from '../../utils/shared-default-props' const I18N = { search: 'Search', + clear: 'Clear', // Accessible label on "clear" button notfound: 'No Emoji Found', skintext: 'Choose your default skin tone', categories: { diff --git a/src/components/search.js b/src/components/search.js index 19992dd..67d8c56 100644 --- a/src/components/search.js +++ b/src/components/search.js @@ -4,12 +4,15 @@ import PropTypes from 'prop-types' import { search as icons } from '../svgs' import NimbleEmojiIndex from '../utils/emoji-index/nimble-emoji-index' +let id = 0 + export default class Search extends React.PureComponent { constructor(props) { super(props) this.state = { icon: icons.search, isSearching: false, + id: ++id, } this.data = props.data @@ -46,6 +49,7 @@ export default class Search extends React.PureComponent { clear() { if (this.input.value == '') return this.input.value = '' + this.input.focus() this.search('') } @@ -64,22 +68,32 @@ export default class Search extends React.PureComponent { } render() { - var { i18n, autoFocus } = this.props - var { icon, isSearching } = this.state + const { i18n, autoFocus } = this.props + const { icon, isSearching, id } = this.state + const inputId = `emoji-mart-search-${id}` return (
+ {/* + * Use a