-
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
Editor: Unify device preview styles #56904
Conversation
Size Change: -216 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
Flaky tests detected in df1360d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7145127382
|
2877fcf
to
447a8c6
Compare
1bd7b7e
to
5b874bf
Compare
@@ -361,6 +372,7 @@ function EditorCanvas( | |||
} | |||
renderAppender={ renderAppender } | |||
/> | |||
<EditTemplateBlocksNotification contentRef={ localRef } /> |
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.
Wasn't this also in the other PR?
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, this is based on the other one :)
447a8c6
to
df1360d
Compare
hasFixedToolbar: | ||
isFeatureActive( 'fixedToolbar' ) || | ||
getDeviceType() !== 'Desktop', | ||
hasFixedToolbar: isFeatureActive( 'fixedToolbar' ), |
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.
Don't we still need this? Although I see the floating toolbar even in trunk for the post editor...
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, it's a left over for a very old 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.
Looks good here.
* WordPress/gutenberg#56921 changed the label of the preview button from "Preview" to "View". * WordPress/gutenberg#56904 removed the setting of an `is-xxx-preview` class when using the in-page preview. Targeting the parent element (that has a static class) instead. * #86033 attempted to fix a test for another Gutenberg change, but the selector used there matches multiple elements in one of our tests and so causes it to fail. Adding `[role="tab"]` into the selector fixes that.
* WordPress/gutenberg#56921 changed the label of the preview button from "Preview" to "View". * WordPress/gutenberg#56904 removed the setting of an `is-xxx-preview` class when using the in-page preview. Targeting the parent element (that has a static class) instead. * #86033 attempted to fix a test for another Gutenberg change, but the selector used there matches multiple elements in one of our tests and so causes it to fail. Adding `[role="tab"]` into the selector fixes that.
@@ -348,6 +357,7 @@ function EditorCanvas( | |||
<BlockList | |||
className={ classnames( | |||
className, | |||
'is-' + deviceType.toLowerCase() + '-preview', |
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.
@youknowriad I got a ping from @sergiu-radu that we previous had this class on the .editor-styles-wrapper
container, and since 6.5 on the .is-root-container
div, so this is a small breaking change. @sergiu-radu, could you maybe give us some more info about why you were relying on 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.
We can consider it adding it to that wrapper too. It would be good to open a detailed issue about 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.
Hi guys 👋
No, this class was not on .editor-styles-wrapper
but outside this container...
To be more specific, this class.is-desktop-preview
was a direct child container of .edit-post-visual-editor__content-area
container and inside it was the .editor-styles-wrapper
.
Here is a screenshot - https://share.cleanshot.com/D1h4tF67
Now, in 6.5 the .is-desktop-preview
class is placed on .is-root-container
and this breaks a lot of things for us, and I think for other classic themes too.
Here is a screenshot - https://share.cleanshot.com/r57zPg57
We will try to make some tests and adjust our code first but if we won't succeed - will open an issue.
Thank you.
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.
To be clear, per the extensibility guidelines of Gutenberg, this is an internal modifier class. It's unfortunate that theme authors are relying on it. We can try to mitigate the issues though (the class will probably end up being present in two places)
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.
@youknowriad Why was it needed to move it from outside the canvas to inside the canvas?
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 PR unified the behavior between post and site editors, which also meant some markup simplification (removing unnecessary wrappers in the post editor)
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.
Hey guys, we made some more investigations and yes, the problem seems to not be related to that class actually but something else (most likely because of 2 scenarios - when we have iframe on desktop and when we don't have the iframe).
We are still investigating this issue and will get back with more details.
Thank you!
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 don't remember exactly but I believe this class was not present at all in the site editor and I just kept it around (for BC) but in a unified place. We can consider moving it to anther place in. EditorCanvas
if needed but it shouldn't be something that the editor implementor have to think about. The device handling moved within EditorCanvas
Related #52632
What?
This PR unifies the way "device styles" are applied between the post and site editors. The way these styles were applied was a bit different between both editors. While both editors used iframes for device previews, one of them applied the styles to an extra wrapper and the other applied it to the iframe directly. This PR unifies both and picked the simplest approach (avoid any extra wrapper, so it uses the site editor approach).
The other thing is that the "template mode" had a "padding" in the post editor but no padding in the site editor around the template. This PR unifies that as well and removes the padding.
Testing Instructions
Check devices previews in both post and site editors.