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

Block Popover: editor canvas as boundary #19322

Merged
merged 4 commits into from
Jan 14, 2020

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Dec 24, 2019

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.

Screenshot 2019-12-24 at 13 47 15

How has this been tested?

Screenshots

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

@ellatrix ellatrix added the [Status] In Progress Tracking issues with work in progress label Dec 24, 2019
@@ -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 ) )
Copy link
Member Author

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?

@ZebulanStanphill
Copy link
Member

The navigation mode toolbar is currently positioned exactly the same as the edit mode toolbar, which results in some weirdness in situations like this:
image
image

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 master. Editing nested blocks close to the right edge of the screen is a lot easier now.

@ellatrix
Copy link
Member Author

@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

@jasmussen
Copy link
Contributor

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?

@ellatrix ellatrix changed the base branch from master to try/reposition-tabbable-inserter January 13, 2020 15:25
@ellatrix
Copy link
Member Author

This PR is blocked by #19596. I rebased this PR to that branch.

@ellatrix ellatrix force-pushed the try/popover-boundary branch from ffff29d to 7c2efe7 Compare January 13, 2020 15:47
@ellatrix ellatrix changed the title [WIP] Popover: different boundary element Block Popover: editor canvas as boundary Jan 13, 2020
@ellatrix ellatrix removed the [Status] In Progress Tracking issues with work in progress label Jan 13, 2020
@ellatrix
Copy link
Member Author

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 }
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

@youknowriad youknowriad left a 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 ?

@ellatrix ellatrix changed the base branch from master to try/move-movers-to-toolbar January 14, 2020 09:36
@ellatrix
Copy link
Member Author

I changed the merge base, but I think that PR will need a rebase.

@youknowriad youknowriad force-pushed the try/move-movers-to-toolbar branch from 2d7bb30 to c25b93e Compare January 14, 2020 09:43
@youknowriad
Copy link
Contributor

I rebased it.

@youknowriad youknowriad merged commit 650b277 into try/move-movers-to-toolbar Jan 14, 2020
@youknowriad youknowriad deleted the try/popover-boundary branch January 14, 2020 09:44
@ellatrix ellatrix added this to the Gutenberg 7.3 milestone Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants