-
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
Image Block: Lightbox does not work #66691
Comments
After testing a few different combinations, this appears to occur when the page contains a Navigation block and an Image block with lightbox enabled. |
@artemiomorales can you take a look at this? @t-hamano what version of WP and GB are you using here? |
@annezazu I've started taking a look 👍 |
I've been able to reproduce this using Gutenberg 19.6.0-rc.3, on both WordPress 6.6.2 and 6.7-RC2. It's only present when Gutenberg is enabled. it seems this has less to do with the lightbox specifically and more to do with Interactivity API internals via #66001 as @t-hamano pointed out. Namely, I see that the error originates in the Navigation block's Perhaps it'd be more apt for @michalczaplinski or @DAreRodz to take a look? |
Checking the Pinging @westonruter , as I don't know how diff --git a/packages/block-library/src/navigation/view.js b/packages/block-library/src/navigation/view.js
index 9da7ab70d8..1f63b9e2a0 100644
--- a/packages/block-library/src/navigation/view.js
+++ b/packages/block-library/src/navigation/view.js
@@ -24,26 +24,26 @@ const { state, actions } = store(
state: {
get roleAttribute() {
const ctx = getContext();
- return ctx.type === 'overlay' && state.isMenuOpen
+ return ctx.type === 'overlay' && state?.isMenuOpen
? 'dialog'
: null;
},
get ariaModal() {
const ctx = getContext();
- return ctx.type === 'overlay' && state.isMenuOpen
+ return ctx.type === 'overlay' && state?.isMenuOpen
? 'true'
: null;
},
get ariaLabel() {
const ctx = getContext();
- return ctx.type === 'overlay' && state.isMenuOpen
+ return ctx.type === 'overlay' && state?.isMenuOpen
? ctx.ariaLabel
: null;
},
get isMenuOpen() {
// The menu is opened if either `click`, `hover` or `focus` is true.
return (
- Object.values( state.menuOpenedBy ).filter( Boolean )
+ Object.values( state?.menuOpenedBy ).filter( Boolean )
.length > 0
);
},
@@ -109,7 +109,7 @@ const { state, actions } = store(
handleMenuKeydown( event ) {
const { type, firstFocusableElement, lastFocusableElement } =
getContext();
- if ( state.menuOpenedBy.click ) {
+ if ( state?.menuOpenedBy.click ) {
// If Escape close the menu.
if ( event?.key === 'Escape' ) {
actions.closeMenu( 'click' );
@@ -160,7 +160,7 @@ const { state, actions } = store(
openMenu( menuOpenedOn = 'click' ) {
const { type } = getContext();
- state.menuOpenedBy[ menuOpenedOn ] = true;
+ state?.menuOpenedBy[ menuOpenedOn ] = true;
if ( type === 'overlay' ) {
// Add a `has-modal-open` class to the <html> root.
document.documentElement.classList.add( 'has-modal-open' );
@@ -169,9 +169,9 @@ const { state, actions } = store(
closeMenu( menuClosedOn = 'click' ) {
const ctx = getContext();
- state.menuOpenedBy[ menuClosedOn ] = false;
+ state?.menuOpenedBy[ menuClosedOn ] = false;
// Check if the menu is still open or not.
- if ( ! state.isMenuOpen ) {
+ if ( ! state?.isMenuOpen ) {
if (
ctx.modal?.contains( window.document.activeElement )
) {
@@ -191,7 +191,7 @@ const { state, actions } = store(
initMenu() {
const ctx = getContext();
const { ref } = getElement();
- if ( state.isMenuOpen ) {
+ if ( state?.isMenuOpen ) {
const focusableElements =
ref.querySelectorAll( focusableSelectors );
ctx.modal = ref;
@@ -202,7 +202,7 @@ const { state, actions } = store(
},
focusFirstElement() {
const { ref } = getElement();
- if ( state.isMenuOpen ) {
+ if ( state?.isMenuOpen ) {
const focusableElements =
ref.querySelectorAll( focusableSelectors );
focusableElements?.[ 0 ]?.focus(); |
How was |
@westonruter I verified via |
Also, only happens in Chrome 😅 |
Well, I'm guessing that Preact is perhaps itself using |
It seems there is also a race condition going on as well. If I do a hard reload of the page, I only get the error with Screen.recording.2024-11-05.11.12.44.webm |
PR incoming. |
See proposed fix in #66772. It doesn't seem to be an issue with Preact at all. In fact, it seems the Interactivity API's |
Description
When I insert an Image block with the lightbox enabled into the content, the lightbox doesn't work. Also, the Navigation block doesn't work either.
The following error is logged in the browser console:
I think this issue is related to #66001. I temporarily reverted #66001 and it fixed the issue.
Step-by-step reproduction instructions
This issue is a bit unstable, refresh your browser a few times if you can't reproduce it.
Screenshots, screen recording, code snippet
89cc186e4553bad95174b37ec3c35dc0.mp4
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
The text was updated successfully, but these errors were encountered: