Skip to content

Fix/73489 - Two dates highlighted when scrolling date list with keyboard arrows on Freq list#74306

Merged
blimpich merged 23 commits intoExpensify:mainfrom
dmkt9:fix/73489
Nov 20, 2025
Merged

Fix/73489 - Two dates highlighted when scrolling date list with keyboard arrows on Freq list#74306
blimpich merged 23 commits intoExpensify:mainfrom
dmkt9:fix/73489

Conversation

@dmkt9
Copy link
Copy Markdown
Contributor

@dmkt9 dmkt9 commented Nov 5, 2025

Explanation of Change

When using the arrow up/down keys to navigate items, the hover style is temporarily disabled to prevent multiple items from appearing highlighted at the same time.
The next item to be focused when pressing the arrow key will be the currently hovered item (similar to Slack's behavior). If no item is being hovered, the focus will move to the item before or after the currently highlighted one.

Fixed Issues

$ #73489
PROPOSAL: #73489 (comment)

Tests

Same as QA Steps

  • Verify that no errors appear in the JS console

Offline tests

Same as QA Steps

QA Steps

Test 1:

  1. Go to a workspace
  2. Enable Workflows
  3. Turn on Submission frequency
  4. Go to the Frequency page
  5. Select Monthly
  6. Open the Date of month dropdown
  7. Hover the mouse over any date
  8. Press Up/Down arrow keys to scroll through the list of dates
  9. Note that only one date should be highlighted, clearly indicating the current selection

Test 2:

  1. Go to a workspace
  2. Enable the "Distance rates" feature
  3. Add rates until the list becomes scrollable
  4. Go to the workspace chat.
  5. Submit a track expense
  6. Open that track expense
  7. Click on the "Rate" field
  8. Hover the mouse over any date
  9. Press Up/Down arrow keys to scroll through the list of dates
  10. Note that only one date should be highlighted, clearly indicating the current selection
  • Verify that no errors appear in the JS console

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
    • MacOS: Desktop
  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • 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

Test 1:

Android: Native

This issue doesn't occur

Android: mWeb Chrome

This issue doesn't occur

iOS: Native

This issue doesn't occur

iOS: mWeb Safari

This issue doesn't occur

MacOS: Chrome / Safari
mac.safari.mp4
MacOS: Desktop
mac.desktop.mp4

Test 2:

2025-11-13.16-59-13.mp4

@dmkt9 dmkt9 requested review from a team as code owners November 5, 2025 10:53
@melvin-bot melvin-bot bot requested review from linhvovan29546 and trjExpensify and removed request for a team November 5, 2025 10:53
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Nov 5, 2025

@linhvovan29546 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 November 5, 2025 10:53
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 5, 2025

Review complete! Found 2 performance-related issues that should be addressed.

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 5, 2025

Codecov Report

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

Files with missing lines Coverage Δ
...components/SelectionList/ListItem/BaseListItem.tsx 90.47% <100.00%> (+0.47%) ⬆️
...onents/SelectionList/ListItem/ListItemRenderer.tsx 75.00% <ø> (ø)
...omponents/SelectionList/ListItem/RadioListItem.tsx 100.00% <ø> (ø)
...ponents/SelectionListWithSections/BaseListItem.tsx 97.77% <100.00%> (+0.10%) ⬆️
...ListWithSections/BaseSelectionListItemRenderer.tsx 88.88% <ø> (ø)
...onents/SelectionListWithSections/RadioListItem.tsx 88.46% <ø> (ø)
src/hooks/useArrowKeyFocusManager.ts 55.73% <100.00%> (+19.53%) ⬆️
src/components/SelectionList/BaseSelectionList.tsx 64.64% <70.58%> (+1.76%) ⬆️
...ListWithSections/BaseSelectionListWithSections.tsx 76.09% <62.50%> (+0.08%) ⬆️
src/components/SelectionList/index.tsx 0.00% <0.00%> (ø)
... and 1 more
... and 21 files with indirect coverage changes

trjExpensify
trjExpensify previously approved these changes Nov 5, 2025
Copy link
Copy Markdown
Contributor

@trjExpensify trjExpensify left a comment

Choose a reason for hiding this comment

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

Makes sense! 👍

P.s Can you try to make your PR titles more reflective of what changes the PR is making, and fill out the explanation of changes section? Thanks!

@dmkt9 dmkt9 changed the title Fix/73489 - Two dates appear highlighted at the same time Fix/73489 - Two dates highlighted when scrolling date list with keyboard arrows on Freq list Nov 6, 2025
@dmkt9
Copy link
Copy Markdown
Contributor Author

dmkt9 commented Nov 6, 2025

Makes sense! 👍

P.s Can you try to make your PR titles more reflective of what changes the PR is making, and fill out the explanation of changes section? Thanks!

Thanks! I've just updated the title and description for this one.

@linhvovan29546
Copy link
Copy Markdown
Contributor

the biggest benefit of focusing the next item from the hovered item

#73489 (comment)
Currently, when we use the arrow keys to navigate, it focuses on the hovered item instead of the next or previous item, as you mentioned.

Screen.Recording.2025-11-06.at.14.53.08.mov

@linhvovan29546
Copy link
Copy Markdown
Contributor

Bug: After scrolling with the keyboard arrows, if you try to scroll the page using the mouse (I’m using an external mouse), the hovered item is no longer focused.

Screen.Recording.2025-11-06.at.15.39.12.mov

const handleMouseLeave = (e: React.MouseEvent<Element, MouseEvent>) => {
const handleMouseLeave = () => {
bind.onMouseLeave();
e.stopPropagation();
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.

Not sure, but I think removing this one might cause a regression.

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.

I’ve added a prop passed down from BaseSelectionListWithSections. By default, we call stopPropagation inside BaseListItem, but for BaseSelectionListWithSections, the propagation is stopped at the View wrapper instead.

</>
);

useEffect(() => {
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.

Can we split this into platform-specific files, like index.ts and index.native.ts, so we don’t need to check the platform manually?

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.

Resolved — I've pushed it into SelectionListWithSections/index.tsx


let lastClientX = 0;
let lastClientY = 0;
const handler = (event: MouseEvent) => {
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.

Would it be possible to move the handler outside the useEffect?

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.

I think keeping it inside useEffect is more efficient, since we don't use that handler elsewhere

dmkt9 and others added 3 commits November 17, 2025 18:36
Co-authored-by: Linh Vo <vovanlinh29546@gmail.com>
@linhvovan29546
Copy link
Copy Markdown
Contributor

I'm asking internal whether we should simply disable this ESLint rule instead of applying the fix in f50a560
, since we already have an issue to tracking it.

@linhvovan29546
Copy link
Copy Markdown
Contributor

@dmkt9 Could you please revert this commit f50a560? We already have an issue tracking this, so in this PR we should simply disable the ESLint rule instead

This reverts commit f50a560.
@dmkt9
Copy link
Copy Markdown
Contributor Author

dmkt9 commented Nov 18, 2025

@dmkt9 Could you please revert this commit f50a560? We already have an issue tracking this, so in this PR we should simply disable the ESLint rule instead

Sure. That commit has been reverted, and this PR is ready.

@linhvovan29546
Copy link
Copy Markdown
Contributor

so in this PR we should simply disable the ESLint rule instead

I mean we should disable the ESLint rule no-restricted-imports too =))

@dmkt9
Copy link
Copy Markdown
Contributor Author

dmkt9 commented Nov 18, 2025

so in this PR we should simply disable the ESLint rule instead

I mean we should disable the ESLint rule no-restricted-imports too =))

Ah, haha. I misunderstood — I assumed we were skipping that check. It's ready again.

@melvin-bot melvin-bot bot requested a review from blimpich November 18, 2025 05:08
@blimpich
Copy link
Copy Markdown
Contributor

@dmkt9 can we make so that code coverage isn't reduced? See #74306 (comment)

It looks you've already written some great tests, but can we increase it just a bit to make that ❌ into a ✅?

@dmkt9
Copy link
Copy Markdown
Contributor Author

dmkt9 commented Nov 20, 2025

@dmkt9 can we make so that code coverage isn't reduced? See #74306 (comment)

It looks you've already written some great tests, but can we increase it just a bit to make that ❌ into a ✅?

The tests have been added. This is now ready for review.

@blimpich blimpich merged commit 847e0d1 into Expensify:main Nov 20, 2025
30 checks passed
@OSBotify
Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/blimpich in version: 9.2.62-0 🚀

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

@zfurtak
Copy link
Copy Markdown
Contributor

zfurtak commented Nov 23, 2025

hello @dmkt9 , I've been working on the new SelectionList component, could you explain why did you modify the component, if the problem was with the other one (WithSections)?

@dmkt9
Copy link
Copy Markdown
Contributor Author

dmkt9 commented Nov 24, 2025

Hi @zfurtak, I modified SelectionList based on @linhvovan29546’s suggestion here #74306 (comment). And I think it makes sense to synchronize the functionality of both components. Does this affect you?

@zfurtak
Copy link
Copy Markdown
Contributor

zfurtak commented Nov 24, 2025

Okay thank you, I understand @linhvovan29546 motivation but while I'm working on the new component, I'm trying very hard to limit the number of props and the component's complexity.
Bear in mind that the main goal is not to have another huge SelectionList, so only add things when necessary :)

@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/marcaaron in version: 9.2.62-5 🚀

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

@samranahm
Copy link
Copy Markdown
Contributor

@dmkt9 Seems like some unit test are failing on main, could you please check.

testID,
shouldUseDefaultRightHandSideCheckmark = true,
shouldHighlightSelectedItem = true,
shouldDisableHoverStyle,
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.

Checklist from #79395:
We need to pass shouldDisableHoverStyle down to UserListItem as well. Without passing it, we see two highlighted states when using keyboard arrow navigation.

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.

7 participants