-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 the navigation issue inside cover blocks #66093
Fix the navigation issue inside cover blocks #66093
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
.click(); | ||
|
||
const menuZIndex = await coverBlockUtils.calculateZIndexContext( | ||
coverBlock.locator( '.wp-block-navigation__responsive-container' ) |
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.
Is there an accessible target we can test against instead of using implementation details like CSS class selectors? getByRole
is generally preferred when selecting elements.
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 doesn't have any accessible semantics. We could use a data-test-id that is only added in certain environments?
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.
After 0a244ec, we removed this part, but we still have one locator
inside the test, similar to the other tests. I hope that's fine to not need change the markup. WDYT?
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.
Is this something that could be addressed in a code quality follow-up to this PR?
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.
Thanks for your patience here @renatho 👍
This PR branch needs rebasing on trunk to pick up the revert of the original approach otherwise the cover styles are broken.
After rebasing locally, I've given this another test and I think it works well.
Trunk | This PR |
---|---|
Screen.Recording.2024-10-15.at.5.01.11.pm.mp4 |
Screen.Recording.2024-10-15.at.5.12.02.pm.mp4 |
Given the false start already with the original PR, I'd like to get a second set of eyes on this latest approach before merging.
This might also buy some time to address feedback around the new test. However, if the test could be a bit brittle or not provide real value, I think we could look to omit it and land this PR without it to make sure it is in 6.7. Just my two cents.
// Add a `has-modal-open` class to the <html> when the responsive | ||
// menu is open. This reproduces the same behavior of the frontend. |
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.
It does feel a bit odd for a block to be manipulating the root node but if this brings it inline with the frontend perhaps it's already been decided this is ok?
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 does feel unusual. Is there any precedent?
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.
Is this actually needed? I used the testing instructions against trunk
and was able to replicate the issue but only on the front of the site and not in the Editor.
Screen.Capture.on.2024-10-15.at.13-07-37.mp4
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.
Unfortunately, it's really needed because also happens in the editor.
Since it's the behavior in the frontend, I think it would be fine to have the same behavior replicated in the editor.
I used the testing instructions against trunk and was able to replicate the issue but only on the front of the site and not in the Editor.
I noticed sometimes some kind of cache. I didn't dig into to figure out, but sometimes when it delayed I restarted the build and restarted the browser, also marking the "Disable cache" in my network tab.
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.
Are there specific steps to replicate that state? I tried following the PR instructions but it didn't manifest. Maybe it was prior to the rebase?
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.
I raised this PR. I'd appreciate if someone could review it to improve the solution.
I also tried to update the fixtures through npm run fixtures:regenerate
, but I received some errors. If someone could explain me what is happening and how I could fix, it would also be very helpful to save some time. =)
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.
I just checked I was wrong about the deprecation and it's transparent for the user
Yep, the only real sign within the editor should be a console message stating the block was migrated.
And the solution of the has-modal-open will be only for backward compatibility
This PR says it should be in the 19.6 release. So if we do go with the alternative solution soon I don't think there'll be any need to keep the .has-modal-open
class styles around for BC. The change introducing it won't have been released in other words.
I'll comment to that effect when I get to review the alternate PR.
I also tried to update the fixtures through npm run fixtures:regenerate, but I received some errors.
Without looking I can't say if this is the reason or not but another misconception about deprecations is that they are chained together to migrate one deprecated version to the next, all the way to the latest version.
Instead, all deprecations need to be updated (if required) to migrate that deprecated version to the latest. We can continue the discussion over on #66249 as needed.
Thanks for spinning it up 🚀
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 PR says it should be in the 19.6 release. So if we do go with the alternative solution soon I don't think there'll be any need to keep the .has-modal-open class styles around for BC. The change introducing it won't have been released in other words.
It's good to have that anyway, so it's fixed everywhere not needing a manual save in all the broken posts/templates. :)
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.
Wasn't the original issue only in the editor? If that's the case, the deprecation will migrate and fix that display without needing further styles.
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.
Connecting the points, I sent an answer here: #66249 (comment)
68f976b
to
b6f62e2
Compare
Rebased the PR now with the revert merged. |
88944b9
to
345c7df
Compare
345c7df
to
0a244ec
Compare
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 working well for me in testing. I agree it's a little unusual to be adding classes at the root node level from within a block in the editor, but I also like that it creates consistency with what's happening on the frontend. Just added a couple of tiny comments (one nit, and one where I think we need to do a tiny bit of cleanup).
Curious to hear what other folks think, too! It's a tiny bit unfortunate that the classname is so generic (has-modal-open
vs wp-block-navigation--has-modal-open
or something like that), but that's not really in scope of this PR.
// Add a `has-modal-open` class to the <html> when the responsive | ||
// menu is open. This reproduces the same behavior of the frontend. |
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 does feel unusual. Is there any precedent?
I agree it feels unusual and I couldn't find a precedent with other core blocks. That said, in this case one of the things I kind of like about adding and removing classes via the useEffect
and attaching to the node, is that the logic is contained within the block itself, and the editor doesn't need to be aware of it — so, we're not handling the state of the modal within the block-editor state for example.
try { | ||
isClickable = await secondInnerContainer.click( { | ||
trial: true, | ||
timeout: 1000, // This test will always take 1 second to run. |
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.
Was this timing simply arbitrary or was there some metric driving it?
@kevin940726 in your testing wisdom do you have any better ideas?
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.
It wasn't metric-driven. I just used a value that I considered "acceptable". I'm looking forward to seeing if @kevin940726 has ideas to improve this. :)
Co-authored-by: Dave Smith <getdavemail@gmail.com>
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.
Appreciate the continued iteration here @renatho 👍
I've given this another smoke test after the latest round of updates and it all seems to still be testing well for me.
I think there's only two questions we need to answer before merging:
- Are we okay with the addition of
has-modal-open
class in the editor to match the frontend? - Is the arbitrary timeout value ok in the e2e test?
For me, I'd rather see bugs fixed than having arguably imperfect solutions blocked when they don't appear to negatively affect much else. So on those grounds I'll give this an approval.
I don't hold that opinion strongly so it would be prudent to wait for a second approval before merging. On that front, it looks like consensus to move forward is starting to coalesce.
I am pretty confident though we can address anything that needs it, in a follow-up.
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.
Thanks for laying out your thoughts @aaronrobertshaw, that matches my thinking, too!
I think there's only two questions we need to answer before merging:
Are we okay with the addition of has-modal-open class in the editor to match the frontend?
In this case, while it is a little unusual, the change is contained in the sense that it only happens when the modal is opened within a navigation block, and the added rules related to that classname are fairly benign. While it'd be good to avoid this approach if possible, right now, this seems like the most expedient fix, and I haven't encountered any conflicts or issues with the approach.
Is the arbitrary timeout value ok in the e2e test?
For now, I'd think so. It's good that we have some e2e test coverage, and tests can be followed up on in subsequent PRs.
So, all up, on balance I think the UX benefits of this fix (that cover blocks aren't popping in randomly from the perspective of a user) outweigh the code quality concerns we've encountered of a block possibly overreaching by updating classnames on the document wrapper.
A +1 to landing from me! Nice work @renatho, thanks for all the back and forth on this.
Thanks for weighing in again @andrewserong 👍 I'll take the liberty to get this merged for @renatho then.
+1 |
Co-authored-by: renatho <renathoc@git.wordpress.org> Co-authored-by: kevin940726 <kevin940726@git.wordpress.org> Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
I just cherry-picked this PR to the wp/6.7 branch to get it included in the next release: d12932b |
Thanks everyone 👍 |
Co-authored-by: renatho <renathoc@git.wordpress.org> Co-authored-by: kevin940726 <kevin940726@git.wordpress.org> Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
What?
Previously, we implemented this fix, but a regression was found, so it was reverted, and we are sending this new fix using a different approach.
Why?
Many users are having and reporting this issue.
See
The reason is that the cover inner blocks container contains a z-index, crating a stacking context for what is inside.
How?
The new solution changes the
z-index
of the cover inner blocks container toauto
when the navigation is open (has-modal-open
applied to thehtml
). I don't consider it as the ideal solution, but it's the simplest and probably the safest one.What I would see as "ideal" (best in terms of good practices of code if we were creating it from scratch) solutions (and the reason that I didn't implement them):
z-index
of the elements, and it would solve the issue. The problem would be the block deprecation and a complex code to maintain both versions to not break the styles on the frontend until the user re-saves the cover block.Testing Instructions
cc @aaronrobertshaw in case you could re-test it.
Screenshots or screencast
Screen.Recording.2024-10-14.at.11.28.51.mp4