-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 search type popover has 2 items highlighted #53330
base: main
Are you sure you want to change the base?
Fix search type popover has 2 items highlighted #53330
Conversation
I didn't update this -1 focused index for the sub menu back button because I think if there is a sub-menu, then the parent menu won't have a selected option. App/src/components/PopoverMenu.tsx Lines 236 to 239 in 1a6f48e
For this one, when we select the item, the popover will be closed or entered in the submenu. I didn't touch this one too because we already reset the focused index when the modal hides. App/src/components/PopoverMenu.tsx Lines 296 to 297 in 1a6f48e
|
src/components/PopoverMenu.tsx
Outdated
useEffect(() => { | ||
if (isVisible) { | ||
return; | ||
} | ||
setFocusedIndex(currentMenuItemsFocusedIndex); | ||
}, [isVisible, currentMenuItemsFocusedIndex, setFocusedIndex]); |
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.
currentMenuItemsFocusedIndex
is changed due to the change in currentMenuItems
which is due to the call setCurrentMenuItems(menuItems)
that is done in the above useLayoutEffect
. This is a known change and not a side effect and it should be done as soon as possible, i.e. call setFocusedIndex
right after setCurrentMenuItems
.
Note: Keep the isVisible condition but add a comment that we don't want the focus index to change if we dynamically change the items e.g.
If we have:
- Item 1 (Selected)
- Item 2 (Focused)
- Item 3
then the selected item is changed (externally), the result should be as follow:
- Item 1
- Item 2 (Focused)
- Item 3 (Selected)
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.
Added comment with the help from ChatGPT.
|
||
// Update the focused item to match the selected item, but only when the popover is not visible. | ||
// This ensures that if the popover is visible, highlight from the keyboard navigation is not overridden | ||
// by external updates to the selected item, preventing user experience disruption. |
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.
// by external updates to the selected item, preventing user experience disruption. | |
// by external updates. |
Explanation of Change
Fixed Issues
$ #50224
PROPOSAL: #50224 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
Prerequisite: have a saved search
For web/desktop: resize it to a small screen
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android.mp4
Android: mWeb Chrome
android.mweb.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
ios.mwe.b.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4