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

Fix 20152: In split bill upon selection of 8 participants first user gets highlighted. #20649

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion src/components/ArrowKeyFocusManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ const propTypes = {

/** If this value is true, then we exclude TextArea Node. */
shouldExcludeTextAreaNodes: PropTypes.bool,

/** If this value is true, then the arrow down callback would be triggered when the max index is exceeded */
shouldTriggerArrowDownWhenMaxIndexExceeded: PropTypes.bool,
Copy link
Contributor

@Julesssss Julesssss Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to think of a simpler name for this.

Maybe something like isArrowDownAllowedBeyondMax or shouldArrowDownExtendBeyondComponent? They kinda suck though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the main purpose of the arrowDown operation in this case is to reset the index of the highlighted item to 0 (introduced in #18955), can we name it shouldResetFocusedIndexWhenMaxIndexExceeded?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the max index exceeded means we've reached the end of the list, we can call it shouldResetIndexOnEndReached
I'm also ok with shouldResetFocusedIndexWhenMaxIndexExceeded, it's long but self-explanatory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like shouldResetIndexOnEndReached, can we use that please

};

const defaultProps = {
disabledIndexes: [],
shouldExcludeTextAreaNodes: true,
shouldTriggerArrowDownWhenMaxIndexExceeded: true,
};

class ArrowKeyFocusManager extends Component {
Expand Down Expand Up @@ -57,7 +61,7 @@ class ArrowKeyFocusManager extends Component {
if (prevProps.maxIndex === this.props.maxIndex) {
return;
}
if (this.props.focusedIndex > this.props.maxIndex) {
if (this.props.focusedIndex > this.props.maxIndex && this.props.shouldTriggerArrowDownWhenMaxIndexExceeded) {
this.onArrowDownKey();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/components/OptionsSelector/BaseOptionsSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ class BaseOptionsSelector extends Component {
focusedIndex={this.state.focusedIndex}
maxIndex={this.state.allOptions.length - 1}
onFocusedIndexChanged={this.props.disableArrowKeysActions ? () => {} : this.updateFocusedIndex}
shouldTriggerArrowDownWhenMaxIndexExceeded={false}
>
<View style={[styles.flexGrow1, styles.flexShrink1, styles.flexBasisAuto]}>
{this.props.shouldTextInputAppearBelowOptions ? (
Expand Down