Skip to content

Commit

Permalink
UIIN-2514 Reset all should shift focus back to search box
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanDenis committed Nov 7, 2023
1 parent 50f2b95 commit dbdf65e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Make Inventory search and browse query boxes expandable. Refs UIIN-2493.
* Added support for `containsAny` match option in Advanced search. Refs UIIN-2486.
* Inventory search/browse: Do not retain checkbox selections when toggling search segment. Refs UIIN-2477.
* Search box/Browse box- Reset all should shift focus back to search box. Refs UIIN-2514.

## [10.0.3] IN PROGRESS

Expand Down
11 changes: 9 additions & 2 deletions src/components/InstancesList/InstancesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class InstancesList extends React.Component {
};
}


componentDidMount() {
const {
history,
Expand All @@ -185,7 +186,7 @@ class InstancesList extends React.Component {
if (hasReset) {
// imperative way is used because it's no option in SearchAndSort reset/focus filters from outside
document.getElementById('clickable-reset-all')?.click();
document.getElementById('input-inventory-search')?.focus();
this.inputRef.current.focus();

history.replace({ search: 'segment=instances' });
}
Expand Down Expand Up @@ -222,6 +223,9 @@ class InstancesList extends React.Component {
parentMutator.records.reset();
}

inputRef = React.createRef();
indexRef = React.createRef();

extraParamsToReset = {
selectedBrowseResult: false,
authorityId: '',
Expand Down Expand Up @@ -390,7 +394,7 @@ class InstancesList extends React.Component {
// https://issues.folio.org/browse/UIIN-1358
storeLastSegment(segment);
facetsStore.getState().resetFacetSettings();
document.getElementById('input-inventory-search').focus();
this.inputRef.current.focus();
}

handleSearchSegmentChange = (segment) => {
Expand Down Expand Up @@ -903,6 +907,7 @@ class InstancesList extends React.Component {
});

facetsStore.getState().resetFacetSettings();
this.inputRef.current.focus();
}

handleSelectedRecordsModalSave = selectedRecords => {
Expand Down Expand Up @@ -1184,6 +1189,8 @@ class InstancesList extends React.Component {
initialResultCount={INITIAL_RESULT_COUNT}
initiallySelectedRecord={getItem(`${namespace}.${segment}.lastOpenRecord`)}
inputType="textarea"
inputRef={this.inputRef}
indexRef={this.indexRef}
resultCountIncrement={RESULT_COUNT_INCREMENT}
viewRecordComponent={ViewInstanceWrapper}
editRecordComponent={InstanceForm}
Expand Down

0 comments on commit dbdf65e

Please sign in to comment.