-
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
Try improving the side UI for nested blocks #5658
Conversation
Okay, I've pushed a lot of fixes to this, and and the nested UI (tested on columns block) is very much improved in this branch compared to master. Here's a recent video: The UI is basically solid, except for one thing. In a943c23, I disabled the ability to hover or even select the parent block (in this case the columns block). Because there is only a tiny sliver of pixels above and below the columns block, the margin essentially, where can hover or select the block. This area will be even smaller, virtually non existant, when we enable margin collapsing. It wasn't working very well at all, so I disabled it pending an explicit action to select the parent block. Here are mockups for how to enable that to happen. When you've a nested block selected, you see this: You can then click the "Quote" icon in the editor bar to move up the breadcrumb trail and select the parent block: Note that in the mockups above, there is no switcher in child blocks, only the parent can be "switched". This can definitely be revisited in the future, but by limiting transformations to the parent block for now we don't have to deal with what happens when you transform a paragraph inside a quote block into a quote (nested quote). Also, the side UI, while bigger and easier to hit in this branch, has additional improvements coming in #5400. Because this PR is in a fairly good place, and because the code is relatively simple, I would recommend the next step is that someone with a little time on their hands (@mtias? @aduth? @youknowriad ) can help implement a way to select the parent block, perhaps the breadcrumb trail mocked up above. Then we can merge this in, and look at making additional enhancements in future PRs. My biggest worry is that this PR balloons and becomes too complex. |
I'll spend some time iterating at a parent selector. |
Note that I think @mtias had some ideas he wanted to try too, possibly related to this. |
33ae11f
to
249bdce
Compare
Rebased to resolve conflicts (squashed in the process). Pushed some (rather incomplete) iterations on a hover toolbar to select block or parent block. Will continue tomorrow, but sharing what I have in case you were itching to start hacking away on (much-needed 😄) design improvements. |
I may revise (simplify) of the implementation if the button is really only meant to navigate one level up to the immediate parent. As-is, if there was double nesting, it would display two buttons, both with "Select parent block" tooltips. Probably not expected, and instead the user, if wanting to navigate upward through to the grandparent block, would select the single "Select parent block" one at a time. |
a51cc30
to
c2c24e9
Compare
Rebased again to resolve conflicts, and updated implementation. On that end, it feels complete. I noticed an issue though, which is that with new styling, it's now impossible to add content to the second column in a newly-created columns block. |
In fact, if you add a Columns block and immediate deselect it, it's impossible to interact with it at all. |
Thank you for working on this. I'm having to wrangle a baby right now but can look later, I'm guessing that it's the pointer events handling acting up on empty columns. |
Yes, the |
The thing I was trying to accomplish by adding that rule, was to prevent hovering of the _columns_block. You can try commenting it out in https://github.com/WordPress/gutenberg/pull/5658/files#diff-80732b9fe9aee13610c0e0b391943f2aR13 the reason being, the only hoverable area for the parent block is a few pixels above and below the entire thing. Which means if you move the mouse from up before the columns block and onto a child block, Perhaps a different approach, simply, is to allow this to happen, and then just remove This might also allow you to select the parent block by clicking an empty column? |
In this video, I gave the columns block a red background, and the child blocks green backgrounds. Note how hovering the red area invokes The problem is, if you first hover the red area, and then move over the green area, This is what I tried to fix using the pointer-events hack, but I'm going to undo that as it's clearly not ideal. On the other hand, it is desirable to be able to click the red area to select the parent block, when for example the right column is not filled out. @aduth do you think it would be feasible, and in scope of this PR, to unset is-hovered on the parent block when hovering a child block? |
@@ -2,6 +2,11 @@ | |||
background: white; | |||
} | |||
|
|||
// Don't show white background when a nesting parent is selected |
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.
What's the reasoning for the white background in the first place?
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 actually can't recall. Hmm. @youknowriad?
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 like it was introduced here: 775428e#diff-c2685bc3733aece65a4ed211668982e0R2
So it's probably related to the ability to colorize paragraph backgrounds. But removing it doesn't seem to make a difference. @jorgefilipecosta any thoughts?
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.
Seems we shouldn't want to assume a white background, especially if the plan is to support themes to define their own editor styles.
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 reason why we set a white background is related to the contrast verification. If the background was never set getComputedStyles returns back background (if I remember correctly). So adding a background fixes the problem. If themes change the background it also works well because as long as a background is set we are able to retrieve it. The problem happens when no background is set. As we get back background color when background is not set we cannot differentiate and assume is white background because in fact it may be set to black. I will try to research this in more detail maybe there is a way to detect when the background is not set and in that case assume white.
Replicate from comment #5273 (comment).
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.
But this only works if the style is explicitly set, i.e. a theme would need to target and override the .editor-block-list__block:not( .is-multi-selected ) .wp-block-paragraph
selector (or selector of equivalent specificity). And the contrast checker would otherwise falsely report contrast issues on the basis of a white background? i.e. if theme actually had black background where a white text would be very contrasting, it would be reported by the editor as an issue.
I'm wondering if it's really worth the trouble to assume a default value (vs. disabling until a background color is known / set).
Alternatively, could we recurse up through parent elements until we find one where background color is not the default value?
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 think we can remove the background color, for now, as it is causing us troubles so we can advance.
After, I really like the idea, of recursively iterating up to the parent elements. And I will try to explore it. If we find it not a good solution than we disable contrast checker for colors not explicitly set.
I'll take a look at this. It may be tricky because of the way events are handled / ignored between parent blocks and their children. |
This may have been easier with the original hover state which was changed in #5078, since previously it was the case that at most one block could be hovered at a time. |
This should be working now in 0d0c8e0. There's an end-to-end test failure that looks legitimate. Investigating now. |
0d0c8e0
to
c8645fd
Compare
Rebased once more. The E2E test failure was due to the fact that we assumed the sibling inserter was positioned after a block, but this was moved in 6203d2c and the test needed to be updated to accommodate (the rebased commit does so). |
Hmm, noticing some weirdnesses with the hover behavior for shared nested blocks (notably, it is difficult to access the "More Options" menu for the shared block of a columns block). |
Last observed issue is noticeable here and not in master, but not entirely relevant to the changes being proposed. Created a separate fix at #5748. |
7c8b7be
to
cee70e6
Compare
Rebased to resolve conflicts. Pushed f67884c to trick the E2E tests into passing by not clicking at the problematic area of the inserter, noting that this is a temporary resolution. Will do a quick review of the code, but otherwise agree we should get this in soon and iterate. |
&.is-hovered { | ||
.editor-block-settings-menu, | ||
.editor-block-mover { | ||
z-index: 9999; // @todo |
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.
Was this planned to be addressed here?
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.
Ack yes that was intended. All it needs is a proper z index with the mixin. I'm out right now but can look later, alternately feel free to push a fix if you have bandwidth.
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 a '.editor-block-mover': 1
z-index as well. Is that one made redundant with this? Can the controls always have a high z-index, even without the is-selected
/ is-hovered
qualifiers? Are they even present when one of those conditions doesn't apply?
In meantime, I've pushed e1336d3 with reference to z-index
list here.
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 believe that as I worked on this, I decided that yes, the side UI can always be above other things, except in the mobile configuration. So I'd think the old one is redundant now.
@aduth was there anything left to fix before merging? |
🔥🎉❤️❤️ |
We should remove the redundant |
Per #5658 (comment), this removes a no-longer-necessary z-index from the map. It is replaced by a different z-index that applies both for the left and right side UI. Test that the movers work in nested, normal, and floated contexts.
Going to take a look, thanks. |
Addresses #5658 (comment). The More button when selecting multiple blocks inside a column wasn't elevated as it should be. This PR addresses that.
This PR leverages the recent block margin refactor to try and improve how nested blocks UI works.
This is a first step, with many possible steps to take in the future, but from a high level it seeks to make immediate improvements to:
It's still very much a work in progress, but even now it has a lot of benefits over master:
There are still many more todos (I won't list them, some of them will be obvious), but before I go too much farther I would love some thoughts on this implementation as it stands.
If the approach has merit, then there is one additional change we should make in this PR before it's ship ready, and that is to ensure that the parent block is easily selectable. One way to do this could be to always show the gray borders around the parent block, when interacting with a child block. An alternative would be to always show a side-UI type-icon in the vicinity of the parent block, which when clicked selects the parent. This could also serve as a drag handle, now that the side UI is stacking.
Additional ideas for future enhancements could be to dim adjecent blocks when a child block is selected. It would also be nice to look at improving how hovering the parent block works. It can be hard to unhover as it stands.
The key point of this PR is to address the side UI and how it affects nested blocks. The approach outlined in this PR was chosen because it was the simplest of them all, and requires the least UI rejiggering to work.
If for whatever reason this approach isn't feasible after all, an alternative approach we've discussed involves surfacing the mobile UI for nested contexts, which would look something like this:
This UI will still definitely be surfaced on phone breakpoints, but the downside it has is that it increases the height of the selected blocks, which presumably can feel jumpy.
Here is some demo markup you can use to test the columns block: