-
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
Image block view script causes errors when client-side navigation is enabled #63880
Comments
This seems to me like the I am not familiar with the assets management of the full-page client-side navigation yet, but @michalczaplinski should be able to provide more details. |
👋 I'm taking a look right now. It seems that this is a problem with full-page navigation and blocks that have state defined on the server side (with We populate the client-side state with the state from the server on the initial load. As an aside, there IS something strange with how the |
I've attempted a fix in #64067 where I just call However, even with that fix present, there is another issue. E.g.:
is not being called after the Image block is added to the page through a full-page navigation. I think this should be fixed once #62734 merged, I'm not 100% sure. |
In the case of full-page navigation, we need to load the @DAreRodz: now that we are working on making the Interactivity API resilient to asynchronous loads, what should happen with a My first instinct tells me that once the store is loaded, the callbacks should be called, but that means making more parts of the store reactive. |
Oh, I see. 😮 Yes, we need to execute those directives again once the callbacks are defined. This could mean that we need to make the whole store reactive... |
I've edited my previous comment because it was somewhat unclear. I hope you managed to understand it regardless 🙂
Yes, exactly. I was hoping that as part of your work in #62734, the callbacks in |
As I mentioned in my previous comment, fixing that is independent of full-page client-side navigation. In full-page client-side navigation, since we are controlling the loading of all assets, we should wait for the JavaScript to execute before updating the DOM, just like we are doing with the CSS. |
I'm not following, could you explain it differently? In the case discussed in this issue, the |
We have been investigating, and indeed, the The issue is that when copying the attributes of the element, the gutenberg/packages/interactivity-router/src/head.ts Lines 91 to 93 in a47a25d
|
Sooo, there are in fact several issues here 😅 : 1. Remove
|
The only scripts we should load are those belonging to the new interactive blocks on the page. We shouldn't load any other scripts, as no other scripts are guaranteed to work. We need to find a way to identify them. |
Agreed, I just don't want to fix everything in one huge PR! 😅 |
Description
I have an Image block with light box enabled. When I have enabled client-side navigation, and I try navigating from the blog archive page to the post with the image block on it, I get errors in the console:
This is the line in question:
gutenberg/packages/block-library/src/image/view.js
Line 362 in db4bad4
It's not just that, however. If I short-circuit that
setButtonStyles
function from running entirely, then when I try to open a lightbox I get another error:This is the line in question:
gutenberg/packages/block-library/src/image/view.js
Line 90 in db4bad4
I'm not seeing this issue in the latest stable Gutenberg (v18.8), except when I try closing as lightbox I am seeing another error:
This error is coming from:
gutenberg/packages/block-library/src/image/view.js
Line 122 in db4bad4
I see this in both a local dev build in wp-env as well as in the stable build from dotorg installed on a vanilla WP install.
Step-by-step reproduction instructions
(The other error from closing the lightbox occurs on Gutenberg 18.8.)
Screenshots, screen recording, code snippet
Screen.recording.2024-07-23.16.53.36.webm
Environment info
I'm testing in Chrome 126.0.6478.132 on ChromeOS. Gutenberg commit db4bad4. Twenty Twenty-Three theme.
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
The text was updated successfully, but these errors were encountered: