Refocus search input every time a person is selected/unselected#2564
Conversation
|
Not technically part of this PR but related; I think something is causing this line: https://github.com/Expensify/Expensify.cash/blob/75c554970f89b926e45f26b15acd2ea10da93ef3/src/components/OptionsSelector.js#L89-L91 to not do anything because when the New Group Page is opened, it doesn't actually focus the text input in the beginning. It's probably because
|
|
Ok Ignore that earlier comment. I couldn't figure out a good solution to fix that problem and it isn't relevant to the original issue anyways. It'll be fine to manually click the search bar when the group chat option selector first opens up. This PR still makes it easy to continue adding people. |
…to amal-new-group-refocus
…to amal-new-group-refocus
| */ | ||
| toggleOption(option) { | ||
| // After toggling an option, refocus the search bar to help find the next selection | ||
| this.optionSelector.textInput.focus(); |
There was a problem hiding this comment.
While this works, it is pretty unusual and we should try to make this call in the direct parent of that text input.
One option could be to use ref forwarding. But in this case, I'd actually suggest we just move this logic closer to the text input. Here's what I'd suggest:
- Create a new method in
OptionsSelectorcalledthis.selectRow() - In that method, do something like this
selectRow() {
this.textInput.focus();
this.props.onSelectRow(...)
}- Update all usages in
OptionsSelectorto passthis.selectRowinstead ofthis.props.onSelectRow - If you only need this behavior sometimes (since I see we are only adding it to
NewGroupPageand not other pages) maybe pass a boolean prop likeshouldFocusOnSelectRowto theOptionsSelector?
|
Alrighty, this is ready for a re-review. |
|
🚀 Deployed to staging in version: 1.0.38-1🚀
|
|
🚀 Deployed to production in version: 1.0.39-5🚀
|
@MonilBhavsar, please review when you get the chance!
CC: @marcaaron, I wasn't sure whether it was fine to reference the ref of a child component like I do here. Wondering if you had ideas about a cleaner approach.
Details
In the Group Chat creator, selecting a user to add will refocus the search bar. This will make it so you don't have to click the search bar again before you search for the next user.
Fixed Issues
Fixes #2452
Tests
Followed the QA steps on a local environment.
QA Steps
Tested On
Screenshots
Web
Mobile Web
Desktop
iOS
Android