Clear search results when clicking a category anchor
parent
47f2341f53
commit
1a3f2525b9
|
@ -56,7 +56,9 @@ export default class Category extends React.Component {
|
||||||
var { height: labelHeight } = this.label.getBoundingClientRect()
|
var { height: labelHeight } = this.label.getBoundingClientRect()
|
||||||
|
|
||||||
this.top = top - parentTop + this.parent.scrollTop
|
this.top = top - parentTop + this.parent.scrollTop
|
||||||
if (height > labelHeight) {
|
if (height == 0) {
|
||||||
|
this.maxMargin = 0
|
||||||
|
} else if (height > labelHeight) {
|
||||||
this.maxMargin = height - labelHeight
|
this.maxMargin = height - labelHeight
|
||||||
} else {
|
} else {
|
||||||
this.maxMargin = 1
|
this.maxMargin = 1
|
||||||
|
|
|
@ -137,18 +137,30 @@ export default class Picker extends React.Component {
|
||||||
|
|
||||||
handleAnchorClick(category, i) {
|
handleAnchorClick(category, i) {
|
||||||
var component = this.refs[`category-${i}`],
|
var component = this.refs[`category-${i}`],
|
||||||
{ scroll, anchors } = this.refs
|
{ scroll, anchors } = this.refs,
|
||||||
|
scrollToComponent = null
|
||||||
|
|
||||||
if (component) {
|
scrollToComponent = () => {
|
||||||
let { top } = component
|
if (component) {
|
||||||
|
let { top } = component
|
||||||
|
|
||||||
if (category.name == 'Recent') {
|
if (category.name == 'Recent') {
|
||||||
top = 0
|
top = 0
|
||||||
} else {
|
} else {
|
||||||
top += 1
|
top += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
scroll.scrollTop = top
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scroll.scrollTop = top
|
if (SEARCH_CATEGORY.emojis) {
|
||||||
|
this.handleSearch(null)
|
||||||
|
this.refs.search.clear()
|
||||||
|
|
||||||
|
window.requestAnimationFrame(scrollToComponent)
|
||||||
|
} else {
|
||||||
|
scrollToComponent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,6 +194,7 @@ export default class Picker extends React.Component {
|
||||||
|
|
||||||
<div ref="scroll" className='emoji-picker-scroll' onScroll={this.handleScroll.bind(this)}>
|
<div ref="scroll" className='emoji-picker-scroll' onScroll={this.handleScroll.bind(this)}>
|
||||||
<Search
|
<Search
|
||||||
|
ref='search'
|
||||||
onSearch={this.handleSearch.bind(this)}
|
onSearch={this.handleSearch.bind(this)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,10 @@ export default class Search extends React.Component {
|
||||||
this.props.onSearch(results)
|
this.props.onSearch(results)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.refs.input.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <input
|
return <input
|
||||||
ref='input'
|
ref='input'
|
||||||
|
|
Loading…
Reference in New Issue