-
Notifications
You must be signed in to change notification settings - Fork 3k
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 off-by-one error in scrollToIndex #9674
Conversation
|
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.
Seems like a logical fix 👍
Fix off-by-one error in scrollToIndex (cherry picked from commit 6299646)
…9674 🍒 Cherry pick PR #9674 to staging 🍒
@@ -226,7 +226,7 @@ class OptionsSelector extends Component { | |||
focusedIndex: newFocusedIndex, | |||
}); | |||
|
|||
if (newOptions.length <= newFocusedIndex) { | |||
if (newOptions.length < newFocusedIndex) { |
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.
@roryabraham when the search query has no results, this check will fail (0 < 0
).
And we'll scroll to index 0 which doesn't exist, causing the app to crash.
Steps
- ⌘ + K
- Search for an user which doesn't exist.
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.
This change is also causing #9685
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.
Thanks for pointing this out. Revert PR here: #9690
🚀 Deployed to production by @roryabraham in version: 1.1.79-17 🚀
|
Details
I'm not able to reproduce the error, but looking at the logs in the video it makes sense that this would fix it. If the length of options is equal to the index, then we'll get an index-out-of-bounds error:
Fixed Issues
$ #9671
Tests
Unknown since the original issue is not consistently reproducible.
QA Steps
Attempt to reproduce #9671 🤷