-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[$250] Comment not deleted when delete button in red and hit enter key #42645
Comments
Triggered auto assignment to @garrettmknight ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Comment not deleted when delete button in red and hit enter key What is the root cause of that problem?Needs focus trap What changes do you think we should make in order to solve the problem?After this PR merged #39520 We need to use focus trap to set the focus inside the delete popup and to set the focus to the delete button What alternative solutions did you explore?To set focus on the button when the component loads, we can use the
Here's the updated code: const confirmButtonRef = useRef(null); // Create a ref for the confirm button
useEffect(() => { if (confirmButtonRef.current) { confirmButtonRef.current.focus(); // Focus the confirm button when the component loads } }, []);
<Button ref={confirmButtonRef} //.. In this updated code, the |
ProposalPlease re-state the problem that we are trying to solve in this issue.Pressing the Enter key when opening the delete confirmation modal doesn't delete the comment/message. What is the root cause of that problem?When the delete confirmation modal is shown, the focus trap from the rn-web Modal focuses on the Cancel button, so pressing Enter will press the Cancel button. We set App/src/components/Button/index.tsx Line 131 in 2514f29
Now, the question is why the cancel button is focused first when we open the confirmation modal. In the confirmation modal, there are 3 focusable elements, the overlay, delete button, and cancel button. The logic of the focus trap is here. It will focus on the first focusable element first and keep the focus when tabbing within the focus trapped element. Here is how it behaves in this GH test case. First, it will focus on the first focusable descendant of the modal, in our case, it's the modal overlay. The modal overlay is saved as the last focused element. At this point, the edit composer is blurred. If the edit composer is blurred, it will set SHOULD_SHOW_COMPOSE_INPUT to true.
SHOULD_SHOW_COMPOSE_INPUT hides the main composer when an edit composer is focused, on small screens only. Besides the SHOULD_SHOW_COMPOSE_INPUT controls the main composer visibility, it also controls the autoFocus behavior. App/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx Lines 288 to 289 in 2514f29
Because SHOULD_SHOW_COMPOSE_INPUT is now true, autoFocus now becomes true too. Before, it was false because an edit composer was focused which set SHOULD_SHOW_COMPOSE_INPUT to false. Now, here's the problem. autoFocus is supposed to work only once when the text input is mounted. However, the live markdown input will focus on the input every time the autoFocus is changed to true. The input focus then triggers the focus trap logic again which first focuses on the first focusable descendant, that is the overlay. Then it checks whether the last (prev) focused element is the same as the current focused element. If it's the same, it will start focusing on the last focusable descendant element. In our case, the last focused element is the overlay and the first focusable descendant is also the overlay, so the focus trap will focus on the last focusable descendant element, that is the cancel button. What changes do you think we should make in order to solve the problem?We can:
but I would like to address the root cause of the issue, that is the input gets focused every time autoFocus is changed which doesn't happen with the react native TextInput. To fix the issue, we should remove autoFocus from the effect deps here This way, it will work as pointed out by the comment, that is to auto-focus only when the component is mounted, not when autoFocus is changed. This happens after this react native live markdown PR which adds the react hooks eslint rule and adds the autoFocus as the deps to fix the lint, but we shouldn't do that for autoFocus case. This will also fix an issue where the main composer is focused every time the edit composer is blurred. Screen.Recording.2024-05-28.at.15.55.48.movAfter this change, the overlay will be the one that is focused when opening the confirmation modal, which is what happens with other confirmation modals. Pressing Enter on the overlay will trigger the |
Job added to Upwork: https://www.upwork.com/jobs/~01b70ac798adfe8d66 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @sobitneupane ( |
Thanks for the proposal everyone. Proposal from @bernhardoj looks good to me. 🎀👀🎀 C+ reviewed |
Triggered auto assignment to @blimpich, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
📣 @bernhardoj 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
The live markdown PR is here |
The live markdown PR is merged and released in 0.7.78, but we can't update it yet because 0.7.76 caused a regression, so we need to wait for a new version that fixes the issue. |
Holding on #42766 |
Still holding on #42766 |
Sweet! @sobitneupane does this mean we can finish with pay out for this issue and close it? cc: @garrettmknight |
@garrettmknight @blimpich @sobitneupane @bernhardoj this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks! |
I can confirm that the issue is resolved. Screen.Recording.2024-06-11.at.12.53.22.mov
Yup. |
Nice one! Payment Summary
@sobitneupane is any of the checklist necessary on this one? |
Regression Test Proposal
Do we agree 👍 or 👎 |
Dropping to weekly for you to request @sobitneupane |
Just awating the reqeust |
@garrettmknight @blimpich @sobitneupane @bernhardoj this issue is now 4 weeks old, please consider:
Thanks! |
Still awaiting payment request |
@garrettmknight, @blimpich, @sobitneupane, @bernhardoj Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
Still awaiting the payment request |
1 similar comment
Still awaiting the payment request |
@sobitneupane I'm gonna close this one, but submit the payment request when you get a chance. |
$250 approved for @sobitneupane |
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: 1.4.76-0
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: @iwiznia
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1716823498553919
Action Performed:
Expected Result:
Message/comment deleted
Actual Result:
Message/comment is not deleted because the focus is on the
cancel
button (even though delete is in red)Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
Recording.128.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @sobitneupaneThe text was updated successfully, but these errors were encountered: