Layout Support: Replace incremental IDs with hashes #68210
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Changes how class names for layout containers are generated, replacing per-block, incrementally-generated IDs with hashes obtained from the layout styles definition.
Will fix #67308.
Why?
Since #67826, the Interactivity API's client-side navigation feature replaces all style sheets when
navigate
is called.This currently affects the style of elements outside of router regions, even when navigating between pages generated with the same template, because layout class names depend on the number of blocks rendered using them (see #67826), which can vary.
How?
The PR adds a new function named
gutenberg_unique_prefixed_id_from_array
, which basically generates a short hash from the passed array.This function is used to generate the layout container class, receiving all the data required to generate the style output. That guarantees hashes to be unique for each layout style combination.
Testing Instructions
TBD
Screenshots or screencast
Screen.Recording.2024-12-20.at.13.45.58.mov
Screen.Recording.2024-12-20.at.13.48.13.mov