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

Fix support of sticky position in non-iframed post editor #53540

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions packages/edit-post/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,19 @@ export default function VisualEditor( { styles } ) {
.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;

const isToBeIframed =
( ( hasV3BlocksOnly || ( isGutenbergPlugin && isBlockBasedTheme ) ) &&
! hasMetaBoxes ) ||
isTemplateMode ||
deviceType === 'Tablet' ||
deviceType === 'Mobile';

return (
<BlockTools
__unstableContentRef={ ref }
className={ classnames( 'edit-post-visual-editor', {
'is-template-mode': isTemplateMode,
'is-isolated': isToBeIframed,
} ) }
>
<motion.div
Expand All @@ -354,14 +362,7 @@ export default function VisualEditor( { styles } ) {
className={ previewMode }
>
<MaybeIframe
shouldIframe={
( ( hasV3BlocksOnly ||
( isGutenbergPlugin && isBlockBasedTheme ) ) &&
! hasMetaBoxes ) ||
isTemplateMode ||
deviceType === 'Tablet' ||
deviceType === 'Mobile'
}
shouldIframe={ isToBeIframed }
contentRef={ contentRef }
styles={ styles }
>
Expand Down
4 changes: 3 additions & 1 deletion packages/edit-post/src/components/visual-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
position: relative;
display: flex;
flex-flow: column;
overflow: hidden;
&.is-isolated {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment prior to this rule explaining why overflow: hidden is only applied when .is-isolated is applied? It's a tricky edge case this one, so could be good to make sure we don't accidentally reintroduce the problem further down the track.

overflow: hidden;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it hurt to always apply this rule?

Copy link
Contributor

@andrewserong andrewserong Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, unfortunately overflow: hidden in the non-iframed editor prevents the styling for sticky positioned blocks from working (E.g. Group block set to sticky).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry, I meant to never apply this rule. There's no comment about why it's needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment with explanation for both cases. I also inverted the application of the class. It seems a hair neater that way as a class isn't added for what is the expected case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry, I meant to never apply this rule. There's no comment about why it's needed

Ah, gotcha. And thanks for adding the explanatory comment @stokesman!

@ellatrix there's a screengrab on the earlier PR that added overflow: hidden over in #49978 — basically, the interaction between the iframed editor and the block toolbar popover results in additional scrollbars when the toolbar goes off screen in long posts if we don't have the rule in place.

}

// Gray preview overlay (desktop/tablet/mobile) is intentionally not set on an element with scrolling content like
// interface-interface-skeleton__content. This causes graphical glitches (flashes of the background color)
Expand Down