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 off-by-one error in scrollToIndex #9674

Merged
merged 1 commit into from
Jul 1, 2022
Merged

Conversation

roryabraham
Copy link
Contributor

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:

image

Fixed Issues

$ #9671

Tests

Unknown since the original issue is not consistently reproducible.

  • Verify that no errors appear in the JS console

QA Steps

Attempt to reproduce #9671 🤷

@roryabraham roryabraham requested a review from NikkiWines July 1, 2022 19:15
@roryabraham roryabraham requested a review from marcaaron as a code owner July 1, 2022 19:15
@roryabraham roryabraham self-assigned this Jul 1, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 2022

⚠️ ⚠️ Heads up! This pull request has the CP Staging label. ⚠️ ⚠️
Merging it will cause it to be immediately deployed to staging, even if the open StagingDeployCash deploy checklist is locked.

Copy link
Contributor

@NikkiWines NikkiWines left a 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 👍

@NikkiWines NikkiWines merged commit 6299646 into main Jul 1, 2022
@NikkiWines NikkiWines deleted the Rory-FixScrollToIndex branch July 1, 2022 20:01
OSBotify pushed a commit that referenced this pull request Jul 1, 2022
Fix off-by-one error in scrollToIndex

(cherry picked from commit 6299646)
OSBotify added a commit that referenced this pull request Jul 1, 2022
@@ -226,7 +226,7 @@ class OptionsSelector extends Component {
focusedIndex: newFocusedIndex,
});

if (newOptions.length <= newFocusedIndex) {
if (newOptions.length < newFocusedIndex) {
Copy link
Member

@rushatgabhane rushatgabhane Jul 3, 2022

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

  1. ⌘ + K
  2. Search for an user which doesn't exist.

Result:
image

Copy link
Member

@rushatgabhane rushatgabhane Jul 3, 2022

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

Copy link
Contributor Author

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

@OSBotify
Copy link
Contributor

OSBotify commented Jul 8, 2022

🚀 Deployed to production by @roryabraham in version: 1.1.79-17 🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants