Reset Auto Layout constraint that pins to a view that is being removed to fix a crash #8540
+6
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #8539
Description
Note: I'm tagging reviewers based on the author/reviewer of the related changes while the author isn't on the team anymore.
The crash
This PR aims to fix a recent crash in release 11.6 that I got to reproduce. The crash happens when the dashboard is showing the Add Product header, then the header is hidden like in landscape mode (the navigation bar is collapsed). Then, the dashboard content view gets replaced (e.g. when analytics is re-enabled) while the Auto Layout constraint that connects the header and the previous content view is being activated separately (
DashboardViewController.observeNavigationBarHeightForHeaderVisibility).The fix
To prevent the Auto Layout constraint from being activated when it includes a view that is being removed from the view hierarchy, the constraint is reset to
nilbefore the content view is removed next. The constraint will be re-established inonDashboardUIUpdate's call toaddViewBelowHeaderStackViewfor the new content view.Testing instructions
Prerequisite: the Add Product banner is shown for the store
/wp-admin/admin.php?page=wc-settings&tab=advanced§ion=featuresto disable analytics (uncheckEnables WooCommerce Analytics)/wp-admin/admin.php?page=wc-settings&tab=advanced§ion=featuresto re-enable analytics (chcekEnables WooCommerce Analytics)RELEASE-NOTES.txtif necessary.