fix webkit CSS, fix clear button

release
Nolan Lawson 2019-03-10 10:35:07 -07:00
parent ef71101cd6
commit bd172943d2
2 changed files with 12 additions and 9 deletions

View File

@ -100,6 +100,14 @@
border-radius: 5px; border-radius: 5px;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
outline: 0; outline: 0;
}
.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 <input type="search">
* via https://stackoverflow.com/a/9422689 */
-webkit-appearance: none; -webkit-appearance: none;
} }

View File

@ -49,6 +49,7 @@ export default class Search extends React.PureComponent {
clear() { clear() {
if (this.input.value == '') return if (this.input.value == '') return
this.input.value = '' this.input.value = ''
this.input.focus()
this.search('') this.search('')
} }
@ -62,20 +63,13 @@ export default class Search extends React.PureComponent {
} }
} }
clearIfNotSearching() {
const { isSearching } = this.state
if (!isSearching) {
this.clear()
}
}
setRef(c) { setRef(c) {
this.input = c this.input = c
} }
render() { render() {
const { i18n, autoFocus } = this.props const { i18n, autoFocus } = this.props
const { icon, id } = this.state const { icon, isSearching, id } = this.state
const inputId = `emoji-mart-search-${id}` const inputId = `emoji-mart-search-${id}`
return ( return (
@ -97,9 +91,10 @@ export default class Search extends React.PureComponent {
</label> </label>
<button <button
className="emoji-mart-search-icon" className="emoji-mart-search-icon"
onClick={this.clearIfNotSearching} onClick={this.clear}
onKeyUp={this.handleKeyUp} onKeyUp={this.handleKeyUp}
aria-label={i18n.clear} aria-label={i18n.clear}
disabled={!isSearching}
> >
{icon()} {icon()}
</button> </button>