Closed m-natarajan closed 1 month ago
Triggered auto assignment to @garrettmknight (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.
Edited by proposal-police: This proposal was edited at 2024-09-05 05:07:41 UTC.
Pressing space in split amount input goes to user's profile
A Pressable
with Button
role will be rendered as button
tag. A DOM button
will trigger onclick
on Spacebar key by default. Reference: https://github.com/necolas/react-native-web/issues/2560#issuecomment-1639812931. You can try it yourself.
When we press the spacebar in the amount tex input, the keyboard event will propagate to the parent Pressable
then trigger the participant item's onPress
and eventually open participant details page.
The problem here are:
onKeyDown
event but only onclick
(i.e. onPress
) event because this is the default browser behavior;Fortunately, we can take advantage of onKeyDownCapture
event which captures all key down events, independent of browser behavior.
isSpaceKeyDownOnInputRef
to detect the Spacebar keydown event in BaseListItem
onKeyDownCapture
:if (e && 'key' in e && e.key === ' ') {
isSpaceKeyDownOnInputRef.current = true;
}
shouldPreventSpaceKeySubmit
prop in BaseListItem
, and early return in onPress
just like shouldPreventEnterKeySubmit
:if (shouldPreventSpaceKeySubmit && isSpaceKeyDownOnInputRef.current) {
isSpaceKeyDownOnInputRef.current = false;
return;
}
shouldPreventSpaceKeySubmit
in BaseSelectionList
;Job added to Upwork: https://www.upwork.com/jobs/~021831765734761522413
Triggered auto assignment to Contributor-plus team member for initial proposal review - @getusha (External
)
Pressing space in split amount input goes to user's profile
when pressing space key while in split amount input (MoneyRequestAmountInput.tsx
) onPress event is triggered, and then it propagates to the parent which is Pressable then the Onpress event gets fired there and so we go to the user's Profile
we can simply ignore the space key while we are in split amount input (MoneyRequestAmountInput.tsx
), by adding this line :
if (key === ' ' || key === 'spacebar) { nativeEvent.preventDefault(); }
to this function textInputKeyPress
https://github.com/Expensify/App/blob/156b8b0da67d1df00b2dbc0aa0f25ed2f03f9ef3/src/components/MoneyRequestAmountInput.tsx#L245-L257
📣 @M00rish! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Edited by proposal-police: This proposal was edited at 2024-09-07 04:48:59 UTC.
Pressing space in the participant's split amount input goes to user's profile page.
The pressable element will role button
will call onpress on space key press also. And we don't have a mechanism to prevent the onPress
event of the PressableWithFeedback
when spacebar is pressed on the input.
onPress
of the PressableWithFeedback
when input is being dragged.setMouseDown
when spacebar is pressed.
https://github.com/Expensify/App/blob/7814fbcf4d0da0d40050670d8129c8aaf759d67e/src/components/MoneyRequestAmountInput.tsx#L242-L257setMouseUp();
when the input is blurred. Or we can use onKeyUp
event to call setMouseUp();
.
https://github.com/Expensify/App/blob/7814fbcf4d0da0d40050670d8129c8aaf759d67e/src/components/MoneyRequestAmountInput.tsx#L293OPTIONAL: We can call setMouseDown();
when input is focused and setMouseUp()
when input is blurred.
We can change the role to menuitem
https://github.com/user-attachments/assets/c0a894e4-018f-4850-aa03-267dca01e158
i'll be OOO next week so if we get proposals ready please ask for another engineer to review. cc @getusha
@garrettmknight, @bondydaa, @getusha Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Reviewing
@garrettmknight i don't think this is worth fixing, entering a space on a number input is unlikely to any user.
I can get behind that.
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.29-6 Reproducible in staging?: y Reproducible in production?: y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: @jayeshmangwani Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1725484726223549
Action Performed:
Action Performed:
Expected Result:
Pressing space should have done nothing, just like any other non-number key press
Actual Result:
Pressing space in split amount input goes to user's profile
Workaround:
unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
https://github.com/user-attachments/assets/8c418dbf-2d57-44ef-89aa-5c3c96ecf12b
https://github.com/user-attachments/assets/2401755b-3fe3-4dcf-b70c-da5f5998717e
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @getusha