-
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 Link UI showing on mount for first and last nav menu items #50638
Conversation
Size Change: +32 B (0%) Total Size: 1.39 MB
ℹ️ View Unchanged
|
74a8ac2
to
774ffe0
Compare
cd8f581
to
f61c627
Compare
02564c5
to
c23b638
Compare
Added a isMounted ref to not check if the link ui should show for the lastInsertedBlock, as there's no way a block could have been added on mount.
1a79aa8
to
fe881da
Compare
Flaky tests detected in fe881da. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5005092371
|
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.
Thank you for working on a fix here.
I've raised a blocking review because I don't think we should be relying on this pattern to achieve the fix.
The "mounted" thing tends to be used when we're obscuring an underlying problem that's more deeply embedded. In this case that's exactly what I think we're doing. More information on the issue here.
I will spin up a PR shortly with an alternative route.
Closing this in favour of #50774. |
Pull request was closed
It was absolutely used as a workaround for a more underlying problem. Thanks for raising a different PR to address it! |
Fixes #50601
What?
Prevents the Link Control UI from showing for empty custom links when the sidebar List View is mounted.
Why?
If you have a custom link without a URL in the first or last spot on your navigation menu, every time the sidebar list view is mounted, the Link Control will show unexpectedly.
How?
There wasn't a way I could find to identify if a block had just been inserted, as on mount the
lastInsertedBlockId
was set to the first item in the existing navigation menu. We know the Link UI should never show when it's first mounted, so I added aisMounted
ref that gets set totrue
after the firstuseEffect
hook is run. This ensures the Link UI won't display on mount.Testing Instructions
Test Setup
Link UI Should not show on mount when the LAST item doesn't have a link
Link UI Should not show on mount when the FIRST item doesn't have a link
Link UI Should Show When Adding a Link
Screenshots or screencast