From 635fa78da90c514452a0c0a80c6d4fc1d88a1754 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 15 Aug 2021 22:41:33 -0400 Subject: [PATCH] Fixed: Cursor Jumps to end in when editing search term Fixes #290 --- frontend/src/Search/SearchFooter.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/frontend/src/Search/SearchFooter.js b/frontend/src/Search/SearchFooter.js index 3288109b2..a69ff04c6 100644 --- a/frontend/src/Search/SearchFooter.js +++ b/frontend/src/Search/SearchFooter.js @@ -27,7 +27,7 @@ class SearchFooter extends Component { this.state = { searchingReleases: false, - searchQuery: defaultSearchQuery, + searchQuery: defaultSearchQuery || '', searchIndexerIds: defaultIndexerIds, searchCategories: defaultCategories }; @@ -52,14 +52,12 @@ class SearchFooter extends Component { isFetching, defaultIndexerIds, defaultCategories, - defaultSearchQuery, searchError } = this.props; const { searchIndexerIds, - searchCategories, - searchQuery + searchCategories } = this.state; const newState = {}; @@ -72,10 +70,6 @@ class SearchFooter extends Component { newState.searchCategories = defaultCategories; } - if (searchQuery !== defaultSearchQuery) { - newState.searchQuery = defaultSearchQuery; - } - if (prevProps.isFetching && !isFetching && !searchError) { newState.searchingReleases = false; } @@ -92,6 +86,10 @@ class SearchFooter extends Component { this.props.onSearchPress(this.state.searchQuery, this.state.searchIndexerIds, this.state.searchCategories); } + onSearchInputChange = ({ value }) => { + this.setState({ searchQuery: value }); + } + // // Render @@ -121,7 +119,7 @@ class SearchFooter extends Component { autoFocus={true} value={searchQuery} isDisabled={isFetching} - onChange={onInputChange} + onChange={this.onSearchInputChange} />