mirror of https://github.com/laurent22/joplin.git
* Fixes #1186, #1354. Clears search when clicking on a notebook. * use new resetSearch method where possible, replaced tabs with spaces * replaced a couple more spaces with tabspull/1597/head
parent
485b4baebb
commit
1eb8df9fa6
|
@ -35,8 +35,7 @@ class HeaderComponent extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.search_onClear = (event) => {
|
this.search_onClear = (event) => {
|
||||||
this.setState({ searchQuery: '' });
|
this.resetSearch();
|
||||||
triggerOnQuery('');
|
|
||||||
if (this.searchElement_) this.searchElement_.focus();
|
if (this.searchElement_) this.searchElement_.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +56,17 @@ class HeaderComponent extends React.Component {
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.search_keyDown = event => {
|
||||||
|
if (event.keyCode === 27) { // ESCAPE
|
||||||
|
this.resetSearch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resetSearch = () => {
|
||||||
|
this.setState({ searchQuery: '' });
|
||||||
|
triggerOnQuery('');
|
||||||
|
}
|
||||||
|
|
||||||
this.searchUsageLink_click = event => {
|
this.searchUsageLink_click = event => {
|
||||||
bridge().openExternal('https://joplinapp.org/#searching');
|
bridge().openExternal('https://joplinapp.org/#searching');
|
||||||
}
|
}
|
||||||
|
@ -68,6 +78,12 @@ class HeaderComponent extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
if(prevProps.notesParentType !== this.props.notesParentType && this.props.notesParentType !== 'Search' && this.state.searchQuery) {
|
||||||
|
this.resetSearch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
if (this.hideSearchUsageLinkIID_) {
|
if (this.hideSearchUsageLinkIID_) {
|
||||||
clearTimeout(this.hideSearchUsageLinkIID_);
|
clearTimeout(this.hideSearchUsageLinkIID_);
|
||||||
|
@ -190,6 +206,7 @@ class HeaderComponent extends React.Component {
|
||||||
ref={elem => this.searchElement_ = elem}
|
ref={elem => this.searchElement_ = elem}
|
||||||
onFocus={this.search_onFocus}
|
onFocus={this.search_onFocus}
|
||||||
onBlur={this.search_onBlur}
|
onBlur={this.search_onBlur}
|
||||||
|
onKeyDown={this.search_keyDown}
|
||||||
/>
|
/>
|
||||||
<a
|
<a
|
||||||
href="#"
|
href="#"
|
||||||
|
@ -257,6 +274,7 @@ const mapStateToProps = (state) => {
|
||||||
return {
|
return {
|
||||||
theme: state.settings.theme,
|
theme: state.settings.theme,
|
||||||
windowCommand: state.windowCommand,
|
windowCommand: state.windowCommand,
|
||||||
|
notesParentType: state.notesParentType,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue