Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll to the top when new options are selected on multiple-selection screens #9626

Merged
merged 5 commits into from
Jul 5, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/components/OptionsSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,6 @@ class OptionsSelector extends Component {
}

this.selectRow(focusedOption);

if (!this.props.canSelectMultipleOptions) {
return;
}

// Scroll back to the top and focus the first unselected item from the list (i.e: the best result according to the current search term)
this.scrollToIndex(0);
this.setState({
focusedIndex: this.props.selectedOptions.length,
});
},
enterConfig.descriptionKey,
enterConfig.modifiers,
Expand Down Expand Up @@ -231,7 +221,7 @@ class OptionsSelector extends Component {
focusedIndex: newFocusedIndex,
});

if (newOptions.length <= newFocusedIndex) {
if (newOptions.length <= newFocusedIndex || !_.isEqual(this.props.selectedOptions, prevProps.selectedOptions)) {
roryabraham marked this conversation as resolved.
Show resolved Hide resolved
return;
}
this.scrollToIndex(newFocusedIndex);
Expand Down Expand Up @@ -320,6 +310,16 @@ class OptionsSelector extends Component {
this.relatedTarget = null;
}
this.props.onSelectRow(option);

if (!this.props.canSelectMultipleOptions) {
return;
}

// Scroll back to the top and focus the first unselected item from the list (i.e: the best result according to the current search term)
this.scrollToIndex(0);
this.setState({
focusedIndex: this.props.selectedOptions.length,
});
}

render() {
Expand Down