-
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
Block Popover: editor canvas as boundary #19322
Conversation
@@ -45,7 +46,7 @@ export function computePopoverXAxisPosition( anchorRect, contentSize, xAxis, cor | |||
popoverLeft: anchorMidPoint, | |||
contentWidth: ( | |||
( anchorMidPoint - ( width / 2 ) > 0 ? ( width / 2 ) : anchorMidPoint ) + | |||
( anchorMidPoint + ( width / 2 ) > window.innerWidth ? window.innerWidth - anchorMidPoint : ( width / 2 ) ) | |||
( anchorMidPoint + ( width / 2 ) > boundaryElement.clientWidth ? boundaryElement.clientWidth - anchorMidPoint : ( width / 2 ) ) |
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'd need to test really long toolbars. Maybe this can be done with CSS though, if the popover is positioned in the boundary element?
The navigation mode toolbar is currently positioned exactly the same as the edit mode toolbar, which results in some weirdness in situations like this: It is also notable that the block mover gets pushed to the left as well, which is not ideal. I think this should probably land around the same time as #18685. Also, the heavy left border on the toolbar no longer fits when the toolbar gets pushed to the left. Aside from those issues, this is a great improvement over |
@ZebulanStanphill this PR is meant to go together with the block mover PR, and it’s not finished. :) @youknowriad feel free to take it and change within your PR |
This is so good, thank you for working on this. One of the concepts being explored in #18667 is to offset the toolbar to the left of the block. Like so: Additionally we are exploring how to surface the block mover only when it's necessary. One early idea is to show those on hover or focus in the toolbar: <img src="https://user-images.githubusercontent.com/548849/69341684-4ca26800-0c6a-11ea-88f1-b9eb44a3a96e.gif" This mover control popping out is obviously going to make the horizontal positioning somewhat more complex, given it makes it wider. Is this something that this PR in question can handle? |
This PR is blocked by #19596. I rebased this PR to that branch. |
ffff29d
to
7c2efe7
Compare
bce6e01
to
9812fe6
Compare
Right. The movers are positioned relative to the block toolbar. We could also split it and use two popovers, but I think it's not worth spending time on it if they'll eventually move back too the toolbar. |
@@ -124,10 +124,14 @@ function BlockPopover( { | |||
className="block-editor-block-list__block-popover" | |||
__unstableSticky={ showEmptyBlockSideInserter ? false : popoverIsSticky } | |||
__unstableSlotName="block-toolbar" | |||
__unstableBoundaryParent | |||
// Allow subpixel positioning for the block movement animation. | |||
__unstableAllowVerticalSubpixelPosition={ moverDirection !== 'horizontal' && node } | |||
__unstableAllowHorizontalSubpixelPosition={ moverDirection === 'horizontal' && node } |
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.
It feels like we have too many unstable props for the Popover
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 😅 Soon we should look into rewriting Popover
or swapping it out, but I'd like to wait for some more simplifications and use cases for positioning.
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.
should we merge this into #18685 ?
I changed the merge base, but I think that PR will need a rebase. |
2d7bb30
to
c25b93e
Compare
I rebased it. |
Description
This is just a proof of concept. I wouldn't recommend using it on its own as it may look a bit strange with the currently block selection style and the movers on the side.
Eventually we should rewrite
Popover
(or use an external component), but I'm trying to avoid that here so it unblocks other work being don.How has this been tested?
Screenshots
Types of changes
Checklist: