-
Notifications
You must be signed in to change notification settings - Fork 4.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
Fix classic menu fallback race condition #48811
Conversation
When there are no navigation or classic menus, there is a fallback to use the page list of the navigation menu. This works well, but it isn't waiting to make sure the request for classic menus has completed before deciding if it should use the classic menu conversion process or fallback to the page list. This commit adds hasResolvedClassicMenu to the useEffect hook and early return to ensure we don't check for which menu to use until we have our classic menu request.
Size Change: +10 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
@jeryj First up, great work tracking this down 👏 Question: is this bug also in evidence on the
|
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.
This is testing fine, and the code makes sense to me. Thank you for investigating this!
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.
Great work, thank you!
Nice one! Glad to know that the flaky test represents an actual bug rather than just a false positive 😅. |
When there are no navigation or classic menus, there is a fallback to use the page list of the navigation menu. This works well, but our check for if we have classic menus isn't waiting until the request for classic menus has completed before deciding if it should use the classic menu conversion process or fallback to the page list.
What?
Adds a check to address a race condition in finding menu fallbacks
Why?
When adding a navigation block to a post, there is inconsistent behavior based on a race condition around menu fallbacks.
How?
This PR adds
hasResolvedClassicMenu
to theuseEffect
hook and early return to ensure we don't check for which classic menu to use as a fallback until our classic menu request has completed.Testing Instructions
1. Switch to a theme with classic menus
2. Delete all navigation post types so we will need a fallback
/wp-admin/edit.php?post_type=wp_navigation
and delete all navigations./wp-admin/edit.php?post_status=trash&post_type=wp_navigation
and permanently delete all navigations.3. Create one classic menu
4. Test the PR
5. e2e tests
This PR fixes the understandably flaky e2e tests #48482. This test is only flaky on a slower connection that will emphasize the race condition, so we need to slow down the e2e test.
In
/playwright.config.ts
add this within theuse
section to slow down the e2e tests:Now, you can run the e2e test 20x in a row. All should pass. On
trunk
, they pass about 50% of the time.