WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.18k forks source link

Lost nuance of hit detection between blocks #28682

Open stokesman opened 3 years ago

stokesman commented 3 years ago

Description

Clicking the area between blocks now always selects the next block whereas before it would select the block closest to the clicked point. Also, the placement of the editing caret appears at the end of the block content whereas before it was placed as close to the clicked point as possible.

UPDATE: Revised title/description and added new screen captures (and removed one old one) in order to more clearly indicate what has changed.

Step-by-step reproduction instructions

  1. In a block editor running the latest Gutenberg from master try clicking just below the visible content of a block and observe which adjacent block is selected.
  2. Try the same on the version of Gutenberg built into WP 5.6 and observe the difference.

Expected behaviour

On a click between blocks, the block closest to the click is selected

Actual behaviour

On a click between blocks, the next block is selected.

Screenshots or screen recording (optional)

WP 5.6 Gutenberg plugin since at least e4eb4be3a9
between-block-selection-WP5 6 between-block-selection-f622315c8f

Gutenberg plugin built from e4eb4be3a9

This video shows that the regression can be particularly frustrating in the case of very short blocks like the Seperator. A click on the line itself appears not to work* and that the click has to be above the line in order to select the Separator.

*The appearance that a click on the line does not work is likely due to the location of the hotspot in the macOS cursor.

https://user-images.githubusercontent.com/9000376/106695956-8a9a5c00-6590-11eb-86ea-6e91b8c2ac61.mp4

WordPress information

Device information

stokesman commented 3 years ago

I dug in a bit and figured this code removed in #27860 looked like the cause. To confirm, I tried a revert of 30fafd0 and dd80022 which did produce a build that resolves this.

youknowriad commented 3 years ago

I'm not sure we should focus the closest point personally. I chose to focus the next block but I think we can choose to focus the "start" of the next block or the "end" of the previous block. I don't think there's a big value in trying to find the horizontal position.

stokesman commented 3 years ago

I think we can choose to focus the "start" of the next block or the "end" of the previous block.

That would address the main concern I mean to raise here that the previous block is never selected.

I'd brought up the caret placement as something that changed, but indeed, it doesn't seem important given that if you intend to set the caret somewhere, it's probably not too hard to hit that spot.