Skip to content

Commit

Permalink
fix webkit CSS, fix clear button
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Mar 10, 2019
1 parent ef71101 commit bd17294
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
8 changes: 8 additions & 0 deletions css/emoji-mart.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@
border-radius: 5px;
border: 1px solid #d9d9d9;
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;
}

Expand Down
13 changes: 4 additions & 9 deletions src/components/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class Search extends React.PureComponent {
clear() {
if (this.input.value == '') return
this.input.value = ''
this.input.focus()
this.search('')
}

Expand All @@ -62,20 +63,13 @@ export default class Search extends React.PureComponent {
}
}

clearIfNotSearching() {
const { isSearching } = this.state
if (!isSearching) {
this.clear()
}
}

setRef(c) {
this.input = c
}

render() {
const { i18n, autoFocus } = this.props
const { icon, id } = this.state
const { icon, isSearching, id } = this.state
const inputId = `emoji-mart-search-${id}`

return (
Expand All @@ -97,9 +91,10 @@ export default class Search extends React.PureComponent {
</label>
<button
className="emoji-mart-search-icon"
onClick={this.clearIfNotSearching}
onClick={this.clear}
onKeyUp={this.handleKeyUp}
aria-label={i18n.clear}
disabled={!isSearching}
>
{icon()}
</button>
Expand Down

0 comments on commit bd17294

Please sign in to comment.