Closed m-natarajan closed 1 month ago
Triggered auto assignment to @mallenexpensify (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-08-12 23:02:25 UTC.
clicking enter on emoji selector for status results in leaving status pane
Form is submitted because of enter press. https://github.com/Expensify/App/blob/adaf5cd8044179fd4cb90b37447eb2ba5d8c6054/src/pages/settings/Profile/CustomStatus/StatusPage.tsx#L167-L176
We should check if the emoji picker is active or not and if it is we will disable press on enter.
disablePressOnEnter={EmojiPickerAction.isEmojiPickerVisible()}
We can focus on the message input box when the modal hides. https://github.com/Expensify/App/blob/adaf5cd8044179fd4cb90b37447eb2ba5d8c6054/src/pages/settings/Profile/CustomStatus/StatusPage.tsx#L189
onModalHide={() => {
inputRef.current?.focus();
}}
We can use useKeyboardShortcut
to capture enter clicks and perform emoji selection.
useKeyboardShortcut(
CONST.KEYBOARD_SHORTCUTS.ENTER,
() => {
let indexToSelect = focusedIndex;
if (highlightFirstEmoji) {
indexToSelect = 0;
}
const item = filteredEmojis[indexToSelect];
if (!item) {
return;
}
if ('types' in item || 'name' in item) {
const emoji = typeof preferredSkinTone === 'number' && item?.types?.[preferredSkinTone] ? item?.types?.[preferredSkinTone] : item.code;
onEmojiSelected(emoji, item);
}
},
{isActive: !isEnterWhileComposition(keyBoardEvent), shouldPreventDefault: true, shouldStopPropagation: true},
);
Edited by proposal-police: This proposal was edited at 2024-08-13 04:48:25 UTC.
Emoji is not selected, and the RHP for status disappears
In FormProvider
:
https://github.com/Expensify/App/blob/adaf5cd8044179fd4cb90b37447eb2ba5d8c6054/src/pages/settings/Profile/CustomStatus/StatusPage.tsx#L167
the disablePressOnEnter
param is false
by default.
When we open emoji picker then press on Enter, the onSubmit
function is triggered:
https://github.com/Expensify/App/blob/adaf5cd8044179fd4cb90b37447eb2ba5d8c6054/src/pages/settings/Profile/CustomStatus/StatusPage.tsx#L173
so the RHP is closed.
When the emoji picker is showing, we shouldn't trigger updateStatus
on Enter:
https://github.com/Expensify/App/blob/adaf5cd8044179fd4cb90b37447eb2ba5d8c6054/src/pages/settings/Profile/CustomStatus/StatusPage.tsx#L98
by adding an early return logic:
if(EmojiPickerAction.emojiPickerRef.current?.isEmojiPickerVisible){
return
}
We can create a new state:
const [isEmojiPickerVisible, setIsEmojiPickerVisible] = useState(false);
onModalHide={() => setIsEmojiPickerVisible(false)}
onWillShow={() => setIsEmojiPickerVisible(true)}
onWillShow,
disablePressOnEnter={isEmojiPickerVisible}
Job added to Upwork: https://www.upwork.com/jobs/~01d3caa8f59dbe1758
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rayane-djouah (External
)
Good catch @dylanexpensify I was able to reproduce. @rayane-djouah , plz review the proposals above.
https://github.com/user-attachments/assets/74042833-4202-49af-8242-6cfdca176f6f
@Krishna2323 @daledah - Thank you for your proposals.
Could you clarify why, on this page for example: https://staging.new.expensify.com/search/filters/category (using SearchMultipleSelectionPicker
), when you search for a category and press the Enter key, the focused category is correctly selected and the form is not submitted (even though we haven't disabled pressOnEnter
for the button)? However, on the status page, if you search for an emoji and press Enter, the form is submitted (the form submit button is pressed) instead of selecting the focused emoji?
https://github.com/user-attachments/assets/28d6430f-c12b-4c03-9c78-32cb5783ea26
@rayane-djouah, I believe that's because on status page when we search for emoji, the emoji is just highlighted not focused. But on categories page the option is both focused and highlighted.
@rayane-djouah, I believe that's because on status page when we search for emoji, the emoji is just highlighted not focused. But on categories page the option is both focused and highlighted.
@Krishna2323 How can we make the emoji focused to be selected correctly on enter key press instead of submitting the form?
@rayane-djouah, I think my proposal has the simplest solution possible for this because if we try to focus emoji on text input change, the focus from the input will we removed on every character entered. You can try focusing on emoji by up/down arrow keys, you will notice the focus from input is removed.
@rayane-djouah, friendly bump for checking comments above ^
@Krishna2323 - I want to make sure we understand the root cause. Could you please explain why the keyDownHandler
is not being called before the form button’s pressOnEnter
event handler? Is this possibly related to how we are subscribing to it here?
Could you please explain why the keyDownHandler is not being called before the form button’s pressOnEnter event handler?
@rayane-djouah, keyDownHandler
is called before button’s pressOnEnter
but the problem is that both event listeners are called.
What I believe is happening is that in EmojiPickerMenu
, we are directly adding the listener to the document, while in the Button
component, we are using useKeyboardShortcut, which utilizes KeyCommand
from react-native-key-command
. Due to this, the listeners are applied differently, and as a result, keyBoardEvent.preventDefault();
and keyBoardEvent.stopPropagation();
do not work as expected.
https://github.com/Expensify/App/blob/578006fe4d2b7ba13155e795bcef541019aad8ea/src/components/Button/index.tsx#L149-L160 https://github.com/Expensify/App/blob/578006fe4d2b7ba13155e795bcef541019aad8ea/src/libs/KeyboardShortcut/index.ts#L2
@Krishna2323's proposal looks good to me. I prefer using the 2nd alternative solution (using useKeyboardShortcut
) as it fixes the root cause
:ribbon::eyes::ribbon: C+ reviewed
Triggered auto assignment to @carlosmiceli, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
📣 @rayane-djouah 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!
📣 @Krishna2323 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!
Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻 Keep in mind: Code of Conduct | Contributing 📖
Deployed to production earlier today Wonder if automation isn't working here (maybe I shoulda waited til Monday before updating the labels)
[!NOTE] The production deploy automation failed: This should be on [HOLD for Payment 2024-09-6] according to https://github.com/Expensify/App/issues/48221 prod deploy checklist, confirmed in https://github.com/Expensify/App/pull/47761#issuecomment-2322121729.
cc @mallenexpensify
Thanks @rayane-djouah , and for linking the deploy checklist too
@rayane-djouah , you might know the answer here in the related Slack thread. https://expensify.slack.com/archives/C01GTK53T8Q/p1725320002440979?thread_ts=1725050431.962859&cid=C01GTK53T8Q
@carlosmiceli, @mallenexpensify, @rayane-djouah, @Krishna2323 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Contributor: @Krishna2323 paid $250 via Upwork Contributor+: @rayane-djouah paid $250 via Upwork, can you please accept the job and reply here once you have? https://www.upwork.com/jobs/~01d3caa8f59dbe1758
@rayane-djouah , can you also fill out the BZ checklist plz? thx
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
Regression Test Proposal
Do we agree 👍 or 👎
@mallenexpensify - Accepted the job and completed the checklist
Thanks @rayane-djouah , I updated the comment above to denote you've been paid.
Test Case is here
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.19-2 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: @dylanexpensify Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1723475125409519
Action Performed:
Expected Result:
emoji is selected and window for emoji search disappears
Actual Result:
emoji is not selected, and the RHP for status disappears
Workaround:
unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
https://github.com/user-attachments/assets/0772fb25-a1e5-4e17-8fe9-149ff453806c
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @mallenexpensify