-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix "Split bill- Own contact gets highlighted when you press down arrow and the highlight goes out of the screen when press down arrow" #10477
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
Changes from all commits
0a220e3
704d654
342481d
d44c976
4eae63c
d1e764a
d66417b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -144,13 +144,19 @@ class BaseOptionsSelector extends Component { | |||||||||||||||||||||
| */ | ||||||||||||||||||||||
| flattenSections() { | ||||||||||||||||||||||
| const allOptions = []; | ||||||||||||||||||||||
| this.disabledOptionsIndexes = []; | ||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any specific reason we're defining it here, rather than the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The state value App/src/components/OptionsSelector/BaseOptionsSelector.js Lines 100 to 109 in dbfd0eb
We need to sync this.disabledOptionsIndexes with this.state.allOptions always
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah we reinit there its fine. Not asking to remove from
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can be defined in constructor but need to empty array at the entry of |
||||||||||||||||||||||
| let index = 0; | ||||||||||||||||||||||
| _.each(this.props.sections, (section, sectionIndex) => { | ||||||||||||||||||||||
| _.each(section.data, (option, optionIndex) => { | ||||||||||||||||||||||
| allOptions.push({ | ||||||||||||||||||||||
| ...option, | ||||||||||||||||||||||
| sectionIndex, | ||||||||||||||||||||||
| index: optionIndex, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
| if (section.isDisabled || option.isDisabled) { | ||||||||||||||||||||||
| this.disabledOptionsIndexes.push(index); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| index += 1; | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
| return allOptions; | ||||||||||||||||||||||
|
|
@@ -265,8 +271,9 @@ class BaseOptionsSelector extends Component { | |||||||||||||||||||||
| ) : <FullScreenLoadingIndicator />; | ||||||||||||||||||||||
| return ( | ||||||||||||||||||||||
| <ArrowKeyFocusManager | ||||||||||||||||||||||
| disabledIndexes={this.disabledOptionsIndexes} | ||||||||||||||||||||||
| focusedIndex={this.state.focusedIndex} | ||||||||||||||||||||||
| maxIndex={this.props.canSelectMultipleOptions ? this.state.allOptions.length : this.state.allOptions.length - 1} | ||||||||||||||||||||||
| maxIndex={this.state.allOptions.length - 1} | ||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am still not confident of the change, so we'll have to counter with the test so that nothing breaks.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of original code was to have a state of no highlighted options when multiple options type, which is the 2nd issue of this GH ( Only one possible regression will be: App/src/components/ArrowKeyFocusManager.js Lines 29 to 31 in dbfd0eb
This case, that single option will not be highlighted by arrow keys in current codebase. If it's fine, leave what it is now. If it's issue, we can fix it by removing that code
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah lets fix it @vladnobenladen
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Completely removing the code won't help.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mananjadhav any issue with it?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we could pass any integer and it can cause if the index is negative. But we can ignore this change as I am also fixing it here #7846 (comment)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, makes sense in case user can pass any bad values like -1, -100 to |
||||||||||||||||||||||
| onFocusedIndexChanged={this.props.disableArrowKeysActions ? () => {} : this.updateFocusedIndex} | ||||||||||||||||||||||
| > | ||||||||||||||||||||||
| <View style={[styles.flex1]}> | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird edge case question: What happens when all the indexes are added to
disabledIndexes?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Infinite loop that case! I fixed it here