-
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 delaying sibling inserter hover events #17240
Conversation
(Whoops) |
Love this, so good: This feels like a VASTLY better experience. Not just because it solves the problem of the resizer, but because it also makes the UI less jumpy and heavy. Two upsides that in my opinion strongly outweigh the theoretical extra time you have to wait if you only want to insert a block using the sibling inserter. Now you got me looking though, and I noticed this: ☝️ I used the inspector to make sure the on-select borders were always visible for all blocks. And in doing so it's clear that the sibling inserter isn't centered between two blocks. Can it be? |
@@ -879,7 +880,17 @@ | |||
|
|||
&:hover, | |||
&.is-visible { | |||
opacity: 1; | |||
// Only show this inserter after a delay. | |||
animation: block-editor-block-list__insertion-point-inserter-fade-in 0.2s ease-out 0.75s; |
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 this is ok, but is there a specific reason you’ve used animation rather than transition and transition-delay? Seems like you could accomplish the same thing with less code using transition.
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.
🤔 Hmm. Yeah — my first inclination was to use that mixin we have, but I bet this would work too (and maybe fix whatever weird bug is preventing the clicks from registering in Safari?). I'll give it a try.
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.
Does the "reduce motion" thing suggest either approach?
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.
Actually — trying this out now: the main issue is that we only want to apply that delay when this animates in. We still want it to fade out as soon as you mouse out.
Transition will apply to both in and out, which means the button will stick around for an extra second after the cursor leaves it.
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.
You can apply different transition-delay to the base selector and the hover. That should do the trick.
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.
Scratch that — I got this working in db9d48a (after a quick DM with @shaunandrews. 😄).
The only caveat is that the pointer-events
animation didn't work when I tried to move it to a transition instead. I kept that as an animation for now, but it still only works in Chrome and Firefox. I'd guess that pointer-events
isn't generally the sort of property that's supposed to be animated, so its behavior isn't quite the same in each browser. 😕
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'd guess that pointer-events isn't generally the sort of property that's supposed to be animated
Exactly. Animating pointer-events
is a hack, and not a reliable solution. This is a tough one to solve with CSS alone. I'd imagine some JS will be required to handle the delay and trigger the state change.
You might be able to rethink the way you're doing the transition to use a parent element to trigger the delay, which might fix the issue with pointer-events
— but JS might be more succinct.
Fixed in 7ee67d7. |
I went down a rabbit hole with this one yesterday afternoon, and hope to spend a little time on it today with fresh eyes. A general update:
|
Alright. I've had lots of time to dig in, and even though I thought I was closer, I hit a wall and it turns out I'm even farther from a solution than originally thought. 😅 These inserters have 4 levels:
All of these levels slightly overlap the preceding block. So in this screenshot, the insertion point area that's highlighted belongs to the paragraph block: That's what we all end up clicking when we reach for the movers. Even if we were to rip out all of the levels below that, the top parent would still be blocking our clicks. I'd been operating under the impression that the final level (the button itself) was the element that was intercepting hovers + clicks. But that's not the case! All of those levels sit on top of the preceding block, so all of them block hovers/clicks. We'd actually need to disable pointer events on that top parent div (and all children) in order to still use the resize controller like normal. But that won't work either: if we turn off pointer events on the parent, then we'll have nothing hover on, which means we'll never end up showing the toggle button in the first place. I haven't yet found a decent solution (css or js) that allows us to let clicks through, but will still trigger the hovers. I've tried some workarounds, but they usually result in two competing hover states firing off, which isn't great: I'm open to solutions to that if anyone has them! But in the meantime I think this PR is likely dead. 😞 To solve the overlap issue, I think the only simple solution would be to narrow the height of the inserter area (the one in that screenshot above), so that it interferes less with the resize controller. Unfortunately, that'd mean that mouse users would have to be a bit more fiddly when they want to activate that inserter: they'd end up with a smaller hover area. Anyway — if nobody has any good suggestions, I think we're good to close this PR in the meantime. |
cc @youknowriad or @ellatrix since you two seem to have lots of creative solutions to these sorts of things. 🙂 In general: we'd like to stop the sibling inserter from blocking clicks, but still keep it hoverable in some way — so that if you were to leave your mouse in between blocks, we would still surface the inserter after a little delay. |
So frustrating! Sorry about that, Kjell. @ZebulanStanphill has an interesting solution that I think may be worth looking into. My favorite part is moving the sibling inserter below the block rather than above it. Could that help resolve some of the overlap? I realize it would overlap in a different way, but it might be in a more intuitive way. |
A spontaneous thought.:) |
This one seems blocked for now — I'm going to close, and we can open a new PR if we find a JS-based solution that works for us. |
Closes #16646.
This picks up on an idea @mapk had: To have the sibling inserter display after a short delay. This allows for users to select controls that would otherwise be blocked by the inserter. For example, in the GIF below you'll see me resizing the spacer block. But if I stop and wait for
0.75s
, it'll bring up the sibling inserter instead.In #17136, @mapk noted some issues around implementing this:
Yeah. 😞 Also, we can't set
display: none
orvisibility: hidden
here because we want the sibling inserter to be selectable by keyboard users. That's the reason why it's technically always visible today.To get around all that, I adopted a sort of weird approach:
pointer-events: none
, so it ignores clicks when it's hidden, but is still focusable via the keyboard.pointer-events: auto
after the same delay used for the parent's animation.A couple caveats:
This is most definitely a hack approach, and I think we could probably come up with something better that uses javascript? But I figured I'd share anyway in case it helps nudge us along, or in case we're able to sort out the issues it has in Safari.