Open lanitochka17 opened 1 week ago
Triggered auto assignment to @anmurali (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.
@anmurali FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
Edited by proposal-police: This proposal was edited at 2024-10-24 19:31:51 UTC.
Search - Unable to perform search by hitting Enter on search bar when expense is selected
pressOnEnter
prop is passed, so the enter press is caught by the button.
https://github.com/Expensify/App/blob/476ad6bcca6de4faac6a41c37874fd9be62ddfe5/src/components/Search/SearchPageHeader.tsx#L367We have several options to solve this.
pressOnEnter
prop.useActiveElementRole
and pass false to pressOnEnter
when activeElementRole
is presentation
.
const activeElementRole = useActiveElementRole();
const disableEnterShortcut = activeElementRole && [CONST.ROLE.PRESENTATION].includes(activeElementRole as 'presentation');
SearchRouterInput
and then we can use textInputRef.current?.isFocused()
to disabled the pressOnEnter
prop. We might also need to use useEffect
to keep the updated value of textInputRef.current?.isFocused()
.pressOnEnter
prop from other pages like workspace categories, tags, etc.useKeyboardShortcut
config we can add captureOnInputs: false
.
https://github.com/Expensify/App/blob/32d4ddf6ee7569dc50d1358104fc5b02d7f6f5f5/src/components/Button/index.tsx#L175-L184captureOnInputs
and then pass it from SearchPageHeader
> ButtonWithDropdownMenu
> Button
.Search - Unable to perform search by hitting Enter on search bar when expense is selected
We have set pressOnEnter
on the drop down button and in side the button we already have a code that disable the shortcut based on the active element role but it only disables it if the active element is presentation, which is correct
https://github.com/Expensify/App/blob/f46bce0b96c533b6aac0e2464ae27615101a7f7d/src/components/Button/index.tsx#L163
but we set our text inputs role as presentation
https://github.com/Expensify/App/blob/f46bce0b96c533b6aac0e2464ae27615101a7f7d/src/components/Search/SearchRouter/SearchRouterInput.tsx#L99
I propose two options
textbox
We will need to add the role here
TEXTBOX: 'textbox',
2. Along with active role element management we can keep track of whether a text input is focused. Here
https://github.com/Expensify/App/blob/f46bce0b96c533b6aac0e2464ae27615101a7f7d/src/components/ActiveElementRoleProvider/index.tsx#L9-L11
const [isTextInputFocused, setIsTextInputFocused] = useState<boolean | null>(null); const handleFocusIn = () => { setRole(document?.activeElement?.role ?? null); setIsTextInputFocused(['INPUT', 'TEXTAREA'].includes(document.activeElement?.nodeName ?? '')); };
....
const value = React.useMemo(
() => ({
role: activeRoleRef,
isTextInputFocused,
}),
[activeRoleRef, isTextInputFocused],
then
const useIsTextInputFocused = () => { const {isTextInputFocused} = useContext(ActiveElementRoleContext); return isTextInputFocused; };
https://github.com/Expensify/App/blob/f46bce0b96c533b6aac0e2464ae27615101a7f7d/src/components/Button/index.tsx#L163
const isTextInputFocused = useIsTextInputFocused(); const shouldDisableEnterShortcut = useMemo( () => isTextInputFocused || (accessibilityRoles.includes(activeElementRole ?? '') && activeElementRole !== CONST.ROLE.PRESENTATION), [activeElementRole, isTextInputFocused], );
### What alternative solutions did you explore? (Optional)
@anmurali Eep! 4 days overdue now. Issues have feelings too...
I don't think it's very clear how this should behave. You are changing the filter criteria, but there is a selected expense. Should the filter results update? What if the selected expense no longer matches the criteria? cc @luacmartins @trjExpensify @JmillsExpensify
I imagine we'd just clear the selection and perform the new Search. cc @JmillsExpensify for your input as well.
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.0.53-1 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Email or phone of affected tester (no customers): applausetester+kh1610015@applause.expensifail.com Issue reported by: Applause - Internal Team
Action Performed:
Expected Result:
App will perform a new search
Actual Result:
The dropdown button is expanded
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/user-attachments/assets/cab1eefa-0d9f-46a0-bb50-052c2c62e1f4
View all open jobs on GitHub