-
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
[HOLD for payment 2023-07-05] [$1000] unlink button appears as disable but able to click for second time #20983
Comments
Triggered auto assignment to @trjExpensify ( |
Bug0 Triage Checklist (Main S/O)
|
ProposalPlease re-state the problem that we are trying to solve in this issue.unlink button appears as disable but able to click for second time What is the root cause of that problem?The problem is related to the timing of the evaluation and the values being used for the disabled prop. upon logging in the children components it seem like the disabled value keeps changing between true and false depending on the value of isLoading and even when flipping isDisabled and isLoading the behaviour is still inconsistent possibly due to the use of the OR || operator in this case. App/src/components/Button/index.js Line 276 in 862955c
What changes do you think we should make in order to solve the problem?We can change the approach to using a function with a more custom and better performing behaviour thus elemenating the unexpected behaviour of the OR || operator disabled={() => {
if(this.props.isDisabled){
return true;
}
if(this.props.isLoading){
return true;
}
}} Uppon logging and testing with this approach the isLoading seem to disable the button when there's actually loading and isDisabled is disabling the button whenever it's true. ResultScreen.Recording.2023-06-14.at.2.48.16.PM.mov |
ProposalPlease re-state the problem that we are trying to solve in this issue.user should not be able to click unlink button or button should not be show as disable What is the root cause of that problem?The root cause of the problem happens https://github.com/Expensify/App/blob/main/src/components/Pressable/PressableWithFeedback.js#L45-L72. The problem here However, if the value of props.disabled changes after the runAfterInteractions function has been called, the new value is not automatically updated in the runAfterInteractions callback. This is because JavaScript works on a closure mechanism, where variables stored in a closure are not automatically updated when their initial value changes. So after the first click it still set What changes do you think we should make in order to solve the problem?We check the function
The solution would be to make sure the InteractionManager.runAfterInteractions is done and then setDisabled in useEffect
Update useEffect make sure order is run correctly.:
Result: Screen.Recording.2023-06-18.at.21.05.16.movWhat alternative solutions did you explore? (Optional)Solution 2: To use the new value of props.disabled in the runAfterInteractions callback, you can do it another way. Instead of storing the props.disabled value in a temporary variable, you can use a ref to keep track of the props.disabled value. When the props.disabled value changes, the ref is automatically updated and used in the runAfterInteractions callback.
And in
Solution 3:
|
ProposalPlease re-state the problem that we are trying to solve in this issue.We can still press once more a "disabled" Unlink button What is the root cause of that problem?The button use a disabled style but not actually disabled. The Unlink button uses a Button component that internally uses PressableWithFeedback. Unlink button will be disabled when we either offline or a message exists (in this case the Link sent message). App/src/pages/signin/UnlinkLoginForm.js Lines 87 to 93 in bee8fd3
And in Button, it will be disabled if either App/src/components/Button/index.js Line 276 in bee8fd3
Everything works fine here. The problem is in PressableWithFeedback. In PressableWithFeedback, we have a logic to disable the button until the onPress (if a Promise) is done. This is done to solve multiple press issue like this #14572 App/src/components/Pressable/PressableWithFeedback.js Lines 56 to 68 in bee8fd3
As soon as we press a button, it will set the Also, we have a App/src/components/Pressable/PressableWithFeedback.js Lines 45 to 47 in bee8fd3
But this doesn't help. This is the scenario in our case:
What changes do you think we should make in order to solve the problem?I think the current code is kinda confusing, so I propose to modify it a little bit.
The new |
This is reproducible. Though the expected result in the OP is a bit ambiguous as written:
@gadhiyamanan I think it's better to confirm expected behaviour for your bug reports versus state them as "either or" to cover bases. @mananjadhav @s77rt @roryabraham I feel like you guys have some context on this PressableWithFeedback stuff from #14572 as well. In this scenario, I presume the button should not be able to be clicked. Can you confirm, and then I'll update the OP and move it on. |
^^ bump on the above please guys so we can keep this moving :) |
@trjExpensify Oops, so sorry didn't see this until now. Feel free to DM or tag me in Slack next time. For the expected behaviour, yes you are right the button should not be clickable. For the RCA, I think both @namhihi237 and @bernhardoj provided the correct RCA. But not sure what solution to go with yet. Also I think this bug exists on |
Okay, excellent. I'm going to update the OP's expected behaviour and apply the label. You want to be C+ on this one given you're here already 😂? |
That would be great 😁 |
Job added to Upwork: https://www.upwork.com/jobs/~01343ca85e7226e7d6 |
Current assignee @trjExpensify is eligible for the External assigner, not assigning anyone new. |
Current assignee @s77rt is eligible for the External assigner, not assigning anyone new. |
@AmjedNazzal Thanks for the proposal. I don't think your RCA is correct. I don't see how the OR operator is the issue here. |
@namhihi237 Thanks for the proposal. Your RCA is correct. I like the first alternative solution (use of |
@hungvu193 Thanks for the proposal. I don't think you RCA is correct. This kind of early return is already implemented in |
Thanks, @s77rt , Currently, I haven't figured out how to further optimize it. I think To clarify we can leave a comment. |
@bernhardoj Thanks for the proposal. Your RCA is correct. I like the proposed solution and the clean up. Can you please apply #20838 (comment) and your solution and confirm that #14572 is still fixed (especially on Android) |
BTW, the issue in not reproducible on |
@namhihi237 Thanks for the quick follow up. For now I think we need to wait on @bernhardoj confirmation on his proposed solution then we can see how to move forward. |
Yes, applying the changes from #20838 (comment) will make the issue reproducible again, and applying my fix still works. But I see we already have |
Triggered auto assignment to @johnmlee101, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
makes sense 👍 |
📣 @bernhardoj You have been assigned to this job by @johnmlee101! |
PR is ready cc: @s77rt |
🎯 ⚡️ Woah @s77rt / @bernhardoj, great job pushing this forwards! ⚡️ The pull request got merged within 3 working days of assignment, so this job is eligible for a 50% #urgency bonus 🎉
On to the next one 🚀 |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.33-4 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-07-05. 🎊 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.
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:
|
|
Thanks, @s77rt! Ignoring this timeline recap, it didn't account for the weekend. Following offers have been sent:
|
@trjExpensify Accepted! Thanks! BTW, the timeline seems correct, isn't it? |
Ah, my eyes are playing tricks on me.. I read it as not being eligible. 😂 I'd applied the bonus anyhow. Also, settled up with you after accepting - thanks! |
Paid @bernhardoj, waiting on @gadhiyamanan to accept the offer. |
Paid @gadhiyamanan, 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:
user should not be able to click the unlink button
Actual Result:
user able to click disable button
Workaround:
Can the user still use Expensify without this being fixed? Have you informed them of the workaround?
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.3.29-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
Notes/Photos/Videos: Any additional supporting documentation
Screen.Recording.2023-06-09.at.5.59.53.PM.mov
Recording.1006.mp4
Expensify/Expensify Issue URL:
Issue reported by: @gadhiyamanan
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1686314130397609
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: