1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00

Fix annoying flicker when entering first query character.

This commit is contained in:
mic074b 2020-01-18 14:16:12 +11:00
parent c856e8d9ac
commit b6db2bf2c5

View File

@ -9,7 +9,7 @@ class NoteSearchBarComponent extends React.Component {
this.state = {
query: '',
resultCount: 0,
backgroundColor: undefined,
};
this.searchInput_change = this.searchInput_change.bind(this);
@ -115,13 +115,17 @@ class NoteSearchBarComponent extends React.Component {
const nextButton = this.buttonIconComponent('fa-chevron-down', this.nextButton_click);
if (this.props.resultCount !== undefined) {
this.state.resultCount = this.props.resultCount;
}
const theme = themeStyle(this.props.theme);
let backgroundColor = theme.backgroundColor;
if (this.state.query.length > 0 && this.state.resultCount === 0) {
backgroundColor = theme.warningBackgroundColor;
const theme = themeStyle(this.props.theme);
if (this.state.query.length === 0 || this.props.resultCount > 0) {
this.state.backgroundColor = theme.backgroundColor;
} else {
this.state.backgroundColor = theme.warningBackgroundColor;
}
} else {
if (this.state.backgroundColor === undefined) {
const theme = themeStyle(this.props.theme);
this.state.backgroundColor = theme.backgroundColor;
}
}
return (
@ -135,7 +139,7 @@ class NoteSearchBarComponent extends React.Component {
onKeyDown={this.searchInput_keyDown}
ref="searchInput"
type="text"
style={{ width: 200, marginRight: 5, backgroundColor: backgroundColor }}
style={{ width: 200, marginRight: 5, backgroundColor: this.state.backgroundColor }}
/>
{nextButton}
{previousButton}