Skip to content
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

Duotone: Action causes premature caching of theme.json block nodes #49323

Closed
aaronrobertshaw opened this issue Mar 24, 2023 · 2 comments
Closed
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended

Comments

@aaronrobertshaw
Copy link
Contributor

Description

In #49103, SVG filter output was limited to only used filters. Part of this approach involved scraping block names using filters via the wp_loaded hook. It appears this is causing the theme.json block node processing to occur before the get_current_screen global function is available which prevents editor-only selectors from being used in theme.json.

Expected Behaviour

Duotone filter processing would occur after we might alter selectors for the editor.

Actual behaviour

Duotone actions cause caching of theme.json block node data prematurely. Duotone filters are also not currently applied to the frontend or post editor, although they do work in the site editor.

Not being able to generate editor-only selectors via theme.json means that #46496 causes a regression with the Image block and the border not being applied to the inline cropping area.

Potential Solutions

  1. Using a hook that executes later. (Blindly updating the hook used by the duotone filter to wp_enqueue_scripts fixes the editor-only selectors although I don't know the implications for duotone)
  2. Somehow invalidate theme.json block metadata cache when retrieving styles for the editor

Step-by-step reproduction instructions

  1. In the post editor and an image block and add a border to it
  2. Select to crop the image and notice the border is lost.
  3. Save the post.
  4. Go to Site Editor and add a global duotone filter to the Image block
  5. Switch back to the post editor and reload it, note that the duotone filter isn't applied
  6. View the post on the frontend, note that the duotone filter isn't displayed there either.

Screenshots, screen recording, code snippet

No response

Environment info

  • WP 6.1 / 6.2
  • Gutenberg trunk

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@aaronrobertshaw aaronrobertshaw added [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi labels Mar 24, 2023
@Mamaduka
Copy link
Member

Hi, @aaronrobertshaw

Is this a duplicate of #49324?

@aaronrobertshaw
Copy link
Contributor Author

Thanks for flagging @Mamaduka.

Yes it's a duplicate, GitHub was having a moment when I submitted the issue form and I didn't realise it had created two.

I'll close this.

@aaronrobertshaw aaronrobertshaw closed this as not planned Won't fix, can't repro, duplicate, stale Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants