-
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
[HOLD for payment 2023-08-08] [$1000] Web - App crashes after pressing Backspace/Delete key in Incorrect magic code page #23596
Comments
Triggered auto assignment to @CortneyOfstad ( |
Bug0 Triage Checklist (Main S/O)
|
Proposal: @tranvantoan-qn ProposalPlease re-state the problem that we are trying to solve in this issue.App crashes after pressing Backspace/Delete key in Incorrect magic code page What is the root cause of that problem?After dragging, the What changes do you think we should make in order to solve the problem?To prevent the crash, add the following condition: if (inputRefs.current[editIndex]) {
inputRefs.current[editIndex].blur();
} |
ProposalPlease re-state the problem that we are trying to solve in this issue.We want the app to not crash when backspace key is pressed on the magic code input (after drag select) What is the root cause of that problem?When we submit the form (it happens when we fill the last cell of input), then we set the focused index to undefined here. And next, when we drag over the whole input, the focus event gets triggered, but we don't update the focused and edit index in that event. And next, when we press backspace, the focused index will still be undefined which causes the editIndex to also become undefined, and on blur, this undefined editIndex crashes the app. What changes do you think we should make in order to solve the problem?I think we should use a single type for focusedIndex, and not use undefined (we can add -1 in place of that). This is important because eventually, we will be moving to typescript. So when we blur the input we should set the focused index to And on focus event, when focusedIndex is
and we update the focus event of text input like this
Now when backspace is pressed, the focusedIndex will be properly defined. I used Focus event triggers before the press event. We can optimize the state updates in this case What alternative solutions did you explore? (Optional)Block the drag selection on the magic code input |
Job added to Upwork: https://www.upwork.com/jobs/~017414e8528c6cdd44 |
Current assignee @CortneyOfstad is eligible for the External assigner, not assigning anyone new. |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt ( |
@s77rt we have a couple of proposals for your review above 👍 TIA! |
ProposalPlease re-state the problem that we are trying to solve in this issue.App crashes when we press Backspace/Delete after dragging the mouse from input box What is the root cause of that problem?Once magic code has been fulfilled, we called App/src/components/MagicCodeInput.js Lines 184 to 186 in 75e737b
App/src/components/MagicCodeInput.js Lines 195 to 200 in 75e737b
What changes do you think we should make in order to solve the problem?We can remove onPress and shift its logic to onFocus method where we perform the below steps which will set the correct index when the drag starts with the input box. As App/src/components/MagicCodeInput.js Lines 197 to 199 in 75e737b
|
@tranvantoan-qn Thanks for the proposal. I don't think your RCA is correct.
This does not seem to be the case, dragging does not affect the |
@huzaifa-99 Thanks for the proposal. Your RCA is not exactly right.
This is a contradiction, if the blur event occurs then the input is actually focused. The root cause here seems to be that even the input is actually focused we don't update the |
@Pujan92 Thanks for the proposal. Your RCA is the most correct here.
Your solution makes sense but I'm afraid it causes a regression (similar to an old bug):
Kooha-2023-07-26-20-03-43.mp4 |
My question with his solution is: If the issue is caused by the onKeyPress event, why did the crash only happen with Backspace or Delete key? and as mentioned "Crash happens only when the text selection is not showing" - so what should be the value for |
@tranvantoan-qn Thanks for the update, but I still don't think this is the root cause. The root cause is that when you try to drag, |
Crash only happens when text selection is not showing because in that case the text input won't be focused. You can verify and type |
@s77rt Thank you for the review, how about we add this condition to the focus event
Updating my proposal.... |
@huzaifa-99 How would that fix the root cause? We need to ensure the following: |
@s77rt Following your explanation, I saw that the activeElement is always pointed to the last field >> so it means |
@s77rt whenever the input is focused, the onFocus is guaranteed to be triggered. When we start to drag over the inputs (important: without pressing on them), the input we drag from becomes focused ex: lets say we drag from the 5th cell, 5th cell will get focused, and this triggers the focus event. In my updated proposal, this is how the onFocus looks like, so whenever input gets focused we will check if no cell is focused i.e
In this demo, i drag from the last input and state updates correctly on focus Screen.Recording.2023-07-27.at.12.47.46.AM.mp4 |
@s77rt I think it is bcoz on changing the text we are not actually focusing on those input boxes. For that, we do need to use App/src/components/MagicCodeInput.js Lines 227 to 228 in ecfbafe
Screen.Recording.2023-07-27.at.2.16.45.AM.mp4 |
@huzaifa-99 I don't see how this is different than @Pujan92's proposal. Also there is no reason to add the |
I'm heading OoO until 8/14, so reassigning BZ to keep an eye on it while I'm out 👍 |
Triggered auto assignment to @JmillsExpensify ( |
Bug0 Triage Checklist (Main S/O)
|
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.48-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2023-08-08. 🎊 After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
For reference, here are some details about the assignees on this issue: As a reminder, here are the bonuses/penalties that should be applied for any External issue:
|
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:
|
|
I am back from OoO, so taking this back over. Thanks @s77rt for the review above! |
Payments have been made! @tranvantoan-qn was paid the reporting amount of $250 Closing! |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Action Performed:
Expected Result:
Application should not crash
Actual Result:
Application crashes
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.3.45-1
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
Notes/Photos/Videos: Any additional supporting documentation
CRASH.mp4
Recording.3910.mp4
Expensify/Expensify Issue URL:
Issue reported by: @tranvantoan-qn
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1690254789469459
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: