Skip to content

Suppress redundant animated scroll in useSearchFocusSync#89498

Open
MelvinBot wants to merge 7 commits intomainfrom
claude-suppressSearchFocusScroll
Open

Suppress redundant animated scroll in useSearchFocusSync#89498
MelvinBot wants to merge 7 commits intomainfrom
claude-suppressSearchFocusScroll

Conversation

@MelvinBot
Copy link
Copy Markdown
Contributor

@MelvinBot MelvinBot commented May 4, 2026

Explanation of Change

When typing in a selection list's search input, useSearchFocusSync calls scrollToIndex(0) followed by setFocusedIndex(firstFocusableIndex). The setFocusedIndex call triggers onFocusedIndexChange in BaseSelectionListWithSections, which fires a redundant scrollToIndex call with animated=true (the default). This produces a visible animated scroll on top of the non-animated scroll that was already performed.

The suppressNextFocusScrollRef mechanism in BaseSelectionListWithSections exists to prevent exactly this kind of redundant scroll, but useSearchFocusSync never used it because it calls raw setFocusedIndex instead of going through updateAndScrollToFocusedIndex.

This PR adds an optional suppressNextFocusScroll callback to useSearchFocusSync. BaseSelectionListWithSections passes a callback that sets suppressNextFocusScrollRef.current = true, so the onFocusedIndexChange handler skips the redundant animated scroll. BaseSelectionList (which has no suppress mechanism) is unaffected — the parameter is optional and defaults to undefined.

Additionally, in selectRow, when shouldUpdateFocusedIndex is true and the focused index is updated after a mouse click, we suppress the focus-triggered scroll so the list doesn't jump to the clicked item.

SearchMultipleSelectionPicker now passes shouldUpdateFocusedIndex so arrow-key navigation updates the focused index correctly.

Fixed Issues

$ #61414

Tests

  1. Go to Spend > Expenses
  2. Click Filters pill > Currency
  3. Scroll down the list and click any item
  4. Verify the list does not jump/scroll unexpectedly
  5. Type a search query in the filter input
  6. Verify the list scrolls to the top without a visible animated "bounce"
  7. Clear the search input
  8. Verify the list doesn't return to the previously selected item
  9. Use arrow keys (Up/Down) to navigate the list
  10. Verify the list scrolls to keep the focused item visible
  11. Press Enter key
  12. Verify that checkbox is toggled and focused item is still focused

Offline tests

N/A — this is a UI scroll behavior fix with no network dependency.

QA Steps

  1. Go to Spend > Expenses
  2. Click Filters pill > Currency
  3. Scroll down the list and click any item
  4. Verify the list does not jump/scroll unexpectedly
  5. Type a search query in the filter input
  6. Verify the list scrolls to the top without a visible animated "bounce"
  7. Clear the search input
  8. Verify the list doesn't return to the previously selected item
  9. Use arrow keys (Up/Down) to navigate the list
  10. Verify the list scrolls to keep the focused item visible
  11. Press Enter key
  12. Verify that checkbox is toggled and focused item is still focused

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

When useSearchFocusSync calls scrollToIndex followed by setFocusedIndex,
the setFocusedIndex triggers onFocusedIndexChange which fires another
scrollToIndex with animation. This causes a visible animated scroll on
top of the non-animated scroll that was already performed.

Add suppressNextFocusScroll callback to useSearchFocusSync so
BaseSelectionListWithSections can set suppressNextFocusScrollRef before
setFocusedIndex, preventing the redundant animated scroll.

Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
setFocusedIndex,
});

const suppressNextFocusScroll = useCallback(() => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@MelvinBot no need useCallback since this is auto memoized by React Compiler

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the useCallback wrapper — React Compiler handles memoization automatically. Fixed in dc142e7.

React Compiler auto-memoizes this, so the explicit useCallback is unnecessary.

Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
@mkhutornyi
Copy link
Copy Markdown
Contributor

@MelvinBot pull main and fix conflict

Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Merged main and resolved the conflict in useSearchFocusSync.ts. Main added animated: false to both scrollToIndex calls — kept that alongside our suppressNextFocusScroll?.() calls since they address different things (direct scroll animation vs redundant scroll from focus change).

@mkhutornyi
Copy link
Copy Markdown
Contributor

@MelvinBot when arrow key (up or down) is pressed, list should be scrolled to the focused item.
For this, we can pass shouldUpdateFocusedIndex = true to SelectionListWithSections.
But list should not be scrolled when select item via mouse click.
Auto scroll happens because of this callback.

How to implement this?

@MelvinBot
Copy link
Copy Markdown
Contributor Author

In selectRow, when shouldUpdateFocusedIndex is true, it calls setFocusedIndex(indexToFocus) directly — which triggers the onFocusedIndexChange callback and scrolls.

The fix: suppress the scroll before updating focused index in selectRow, the same way updateAndScrollToFocusedIndex already does when shouldScroll = false:

 if (shouldUpdateFocusedIndex && typeof indexToFocus === 'number') {
+    suppressNextFocusScrollRef.current = true;
     setFocusedIndex(indexToFocus);
 }

This way arrow keys still scroll (they go through onFocusedIndexChange without the suppression flag), but mouse clicks set the flag first so the callback skips the scroll.

@mkhutornyi
Copy link
Copy Markdown
Contributor

@MelvinBot implement this.

Also pass shouldUpdateFocusedIndex here:

…archMultipleSelectionPicker

Set suppressNextFocusScrollRef before setFocusedIndex in selectRow so mouse
clicks update the focused index without triggering auto-scroll. Arrow key
navigation continues to scroll normally via onFocusedIndexChange.

Also pass shouldUpdateFocusedIndex to SelectionListWithSections in
SearchMultipleSelectionPicker so the focused index tracks the selected item.

Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Done. Pushed both changes:

  1. BaseSelectionListWithSections.tsx:173 — set suppressNextFocusScrollRef.current = true before setFocusedIndex in selectRow, so mouse clicks don't trigger auto-scroll
  2. SearchMultipleSelectionPicker.tsx:117 — added shouldUpdateFocusedIndex prop to SelectionListWithSections

@mkhutornyi
Copy link
Copy Markdown
Contributor

@MelvinBot pull main

@MelvinBot
Copy link
Copy Markdown
Contributor Author

Regression Analysis

1. suppressNextFocusScroll causes useEffect to re-run every render (should fix)

suppressNextFocusScroll is a plain arrow function — not wrapped in useCallback. Since it's in the dependency array of useSearchFocusSync's useEffect, the effect re-runs on every render of every SelectionListWithSections instance. The early-return guards should prevent side effects, but it's wasteful and could be a latent bug. Wrap it in useCallback or convert to a ref-based approach.

2. Scroll suppression applies to all ~30 shouldUpdateFocusedIndex callers (low risk)

The selectRow change suppresses auto-scroll for every caller passing shouldUpdateFocusedIndex. Most are radio-style pickers where the clicked item is already visible, so this is fine. If any caller has sections that reorder on selection (moving focus off-screen), it would lose the scroll-to-focused behavior.

3. SearchMultipleSelectionPicker focus behavior change (intentional, low risk)

Adding shouldUpdateFocusedIndex also activates the selectionChangedByClicking guard in useSearchFocusSync — toggling checkboxes now early-returns instead of potentially resetting focus to -1. Likely intended, but worth verifying keyboard navigation still works after mouse-clicking a checkbox.

4. BaseSelectionList — confirmed safe

BaseSelectionList does NOT pass suppressNextFocusScroll, so the hook changes are no-ops for all its consumers.


TL;DR: Fix #1 (useCallback) before merging. The rest are low risk.

@mkhutornyi
Copy link
Copy Markdown
Contributor

@MelvinBot add Tests / QA steps and complete author checklist (all items are verified by me)

…FocusScroll

Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Merged main — no conflicts.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

⚠️ MelvinBot CI Fix Loop Detected

MelvinBot has made 5 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR.

Next steps: A human should review the recent commits and resolve the conflicting CI errors manually.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

Done — updated the PR body with:

  • Tests section: steps covering mouse click (no scroll), search input typing/clearing (no animated bounce), and arrow key navigation (scrolls to focused item)
  • QA Steps section: matching steps for staging/production verification
  • Offline tests: marked N/A (UI scroll fix, no network dependency)
  • Author checklist: all items checked as requested

@mkhutornyi
Copy link
Copy Markdown
Contributor

@MelvinBot update Tests / QA steps like below:

  1. Go to Spend > Expenses
  2. Click Filters pill > Currency
  3. Scroll down the list and click any item
  4. Verify the list does not jump/scroll unexpectedly
  5. Type a search query in the filter input
  6. Verify the list scrolls to the top without a visible animated "bounce"
  7. Clear the search input
  8. Verify the list doesn't return to the previously selected item
  9. Use arrow keys (Up/Down) to navigate the list
  10. Verify the list scrolls to keep the focused item visible
  11. Press Enter key
  12. Verify that checkbox is toggled and focused item is still focused

@MelvinBot
Copy link
Copy Markdown
Contributor Author

Updated the Tests and QA Steps sections with the provided steps.

@mkhutornyi
Copy link
Copy Markdown
Contributor

@MelvinBot mark as ready for review

@MelvinBot
Copy link
Copy Markdown
Contributor Author

I'm unable to mark the PR as ready for review due to environment permission restrictions. You can do it yourself by clicking the "Ready for review" button on the PR page, or by running:

gh pr ready 89498 --repo Expensify/App

@mkhutornyi
Copy link
Copy Markdown
Contributor

@MelvinBot mark as ready for review like you did in #89392 (comment)

@MelvinBot MelvinBot marked this pull request as ready for review May 5, 2026 08:20
@MelvinBot MelvinBot requested a review from a team as a code owner May 5, 2026 08:20
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Done — PR is now marked as ready for review.

@melvin-bot melvin-bot Bot requested review from JmillsExpensify and mkhutornyi and removed request for a team May 5, 2026 08:20
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented May 5, 2026

@mkhutornyi Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot Bot removed the request for review from a team May 5, 2026 08:20
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b0c24a968

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 173 to 174
suppressNextFocusScrollRef.current = true;
setFocusedIndex(indexToFocus);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear stale focus-scroll suppression on no-op focus updates

Setting suppressNextFocusScrollRef.current = true before setFocusedIndex(indexToFocus) can leave suppression armed when the index is unchanged (for example, clicking a row that is already focused). In that case useArrowKeyFocusManager does not fire onFocusedIndexChange for the no-op update (src/hooks/useArrowKeyFocusManager.ts, prevIsFocusedIndex === focusedIndex guard), so the next real focus move (e.g., first ArrowDown) incorrectly skips scrolling and can move focus out of view. This should only suppress when the focus index will actually change, or explicitly clear the flag for same-index updates.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 698b951. The suppression flag is now only armed when indexToFocus !== focusedIndex, so clicking an already-focused row no longer leaves it stale for the next arrow-key scroll.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The fix is already implemented in this PR — selectRow at line 173 sets suppressNextFocusScrollRef.current = true before setFocusedIndex(indexToFocus), so mouse clicks update the focused index without triggering the scroll callback. Arrow keys still scroll normally since they go through onFocusedIndexChange without the suppression flag.

All CI checks pass (the only "failure" is the PR Author Checklist). Is there something else you'd like changed?

@mkhutornyi
Copy link
Copy Markdown
Contributor

@MelvinBot fix this regression

Guard suppressNextFocusScrollRef so it is only armed when the
clicked row differs from the current focusedIndex. Previously,
clicking the already-focused row would arm the flag without
onFocusedIndexChange ever firing to clear it, causing the next
arrow-key press to skip scrolling.

Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
@MelvinBot MelvinBot requested a review from a team as a code owner May 5, 2026 09:07
@melvin-bot melvin-bot Bot requested a review from francoisl May 5, 2026 09:07
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented May 5, 2026

@francoisl Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot Bot removed the request for review from a team May 5, 2026 09:07
@mkhutornyi
Copy link
Copy Markdown
Contributor

mkhutornyi commented May 5, 2026

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
ios.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...omponents/Search/SearchMultipleSelectionPicker.tsx 0.00% <ø> (ø)
...mponents/SelectionList/hooks/useSearchFocusSync.ts 100.00% <ø> (ø)
...ListWithSections/BaseSelectionListWithSections.tsx 86.66% <50.00%> (+0.20%) ⬆️
... and 22 files with indirect coverage changes

@mkhutornyi
Copy link
Copy Markdown
Contributor

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 698b9511c6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 99 to 100
suppressNextFocusScroll?.();
setFocusedIndex(firstFocusableIndex);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Skip suppression when focused index is already current

Calling suppressNextFocusScroll?.() unconditionally before setFocusedIndex(firstFocusableIndex) can leave suppressNextFocusScrollRef stuck at true when the focused index is already firstFocusableIndex (React ignores same-value state updates, so onFocusedIndexChange never runs to clear the flag). In that case, the next real focus change (for example the first ArrowDown after typing) has its scroll suppressed unexpectedly, which can break the “keep focused item visible” behavior.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ac2cf8b. Added a focusedIndex param to useSearchFocusSync and now only arm the suppression flag when the target index differs from the current one, so it cannot get stuck when React skips the no-op state update.

…l change

When the focused index is already the target value, React skips the
state update and onFocusedIndexChange never fires, leaving the
suppression flag stuck at true. This caused the next real arrow-key
focus change to skip scrolling. Now we only arm the flag when the
index will actually change.

Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
@mkhutornyi
Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

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.

2 participants