-
Notifications
You must be signed in to change notification settings - Fork 133
Fix crash on order details when tapping customer info buttons #12920
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
Fix crash on order details when tapping customer info buttons #12920
Conversation
When we don't handle this check, there are cases where the click might occur when the navController is not attached anymore, and would cause a crash.
Generated by 🚫 Danger |
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use two fingers to tap instantly on both:
The shipping section of order details.
The row of another order.
🤯🤯
This test case is from another level @hichamboushaba. Great creativity coming up with this case 👏
I tested the PR and can confirm that the change fixes the bug.
LGTM!
} | ||
|
||
private fun navigateToShippingAddressEditingView(address: Address) { | ||
if (!isAttachedToWindow) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple and elegant solution. Great work!
Closes: #12913
Closes: #12919
Description
This PR fixes a crash that can occur in order details screen when tapping on of the buttons of the
OrderDetailCustomerInfoView
, the crash occurs if the user tries to tap on the buttons after the view was detached from the window, this can happen during transition animations, and happens more frequently on tablets given how the navigation works with the dual pane mode.For technical side, this crash happens because when the fragment view is destroyed, the
NavHostFragment
will detach thenavController
, so if a button click listener was to be invoked after this, thefindNavController
will throw the exception.Steps to reproduce
Please repeat the following on both
trunk
and this branch to confirm the fix.trunk
, and shouldn't crash on this branch.Alternatively, if the above wasn't enough to reproduce it, please apply the following patch to simulate it, the patch will trigger manually the click after the view is destroyed, which should cause the crash on
trunk
and would confirm the fix of this branch.Patch
RELEASE-NOTES.txt
if necessary. Use the "[Internal]" label for non-user-facing changes.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: