-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Pattern block: remove wrapping div #36090
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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 works, it makes the "pattern block" a temporary block (only used to load the template to the editor) but there's a gotcha.
Previously, changes were only saved if the pattern itself was modified, now the pattern will stop being used as soon as the template (or template part) where it's used is modified.
I'm fine with the change if you're fine with this behavior.
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.
Personally I would prefer to keep the previous behaviour as it keeps the templates more flexible. Could we use an invisible wrapper, like React.Fragment?
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.
There's also the possibility of using a
<div>
withdisplay: contents
, although there's an accessibility bug with it in Safari at the moment that may make it a non-starter for the time being. https://caniuse.com/css-display-contentsThere 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.
Generally, this seems fine to me. Given our current use cases at least, the translation has already been done at that point. Can someone think of a use case where that wouldn't be 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.
The use case would be that the user changes their site language after they edit a template. With this change, once a user selects a site language they will need to update their templates with new translations.
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 will try this.
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 gave this a try and
<Fragment>
+ inner blocks does not have the desired effect.I also tested a few more scenarios, and I don't think the templates are more that much more flexible with the previous behavior. Take the following example on
trunk
:This will still cause the pattern to no longer from the pattern file.
With this PR, you can still make changes to other template parts, and the pattern will still pull from the file.
How common is this? The problems of alignment introduced by adding this additional wrapper are significant, so would love to find a solution here that doesn't introduce it.
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.
Yeah, I think in general that use case seems like an edge case to me. As @jffng noted, the approach in this PR eliminates a somewhat prominent layout issue, so I'd be happy to settle for what's in this PR and consider anything beyond this behavior to be an enhancement or bug fix later on.
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 agree that the approach in this PR is good enough for now and an improvement over
master
.Also, I don't really know if it's applicable here, and it's certainly beyond the scope of this PR, but just to throw the idea out there: I wonder if we could find a solution via Shadow DOM? Browser support looks viable.
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.
Happy to ship with this compromise for now