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

Reduce minimum spacer height to 1px, while still retaining clickable area #25528

Merged
merged 1 commit into from
Sep 24, 2020

Conversation

jasmussen
Copy link
Contributor

@jasmussen jasmussen commented Sep 22, 2020

This PR takes a different approach to allowing a 1px tall spacer block. Alternative to #25525. Fixes #18906. Mitigates #24460.

The primary problem is that the sibling inserter above and below a 1px spacer block makes it appear hard to select the spacer.

It does a few things. First off, through a line height it fixes an issue with the sibling inserter being too tall. That red area is the clickable area shown for debug purposes:

Screenshot 2020-09-22 at 09 29 41

Screenshot 2020-09-22 at 09 29 58

Fixed:
Screenshot 2020-09-22 at 09 31 52

It alos changes the sibling inserter cursor from being hardcoded to text, to not being changed at all. In practice that means when you try to click a 1px spacer, you're technically clicking the sibling inserter hover area, but that area redirects to the nearest block which in most cases means the spacer block. So this is more of a visual change — when the cursor was text it didn't seem like a click would select the spacer block when in fact it would:

click

And finally, it adds a hidden "sizer" above the spacer block which provides a minimum clickable area:

click resizer

Here, it's shown in red, that's only for debug purposes. I believe we tried this in the past and it didn't work, but it seems to work fine here:

click resizer

CC and props: @stokesman for the initial work.

This PR takes a different approach to allowing a 1px tall spacer block.

The primary problem is that the sibling inserter above and below a 1px spacer block makes it appear hard to select the spacer.

This PR addresses that primarily by changing the cursor from being hardcoded to `text`, to not being changed at all. In practice that means when you try to click a 1px spacer, you're technically clicking the sibling inserter hover area, but that area redirects to the nearest block which in most cases means the spacer block.
@jasmussen jasmussen added the [Type] Enhancement A suggestion for improvement. label Sep 22, 2020
@jasmussen jasmussen self-assigned this Sep 22, 2020
@jasmussen
Copy link
Contributor Author

Note that the uncentered plus that's becoming visible due to the red debug color is a separate issue that I believe @ellatrix has tracked separately. And the jumpiness with the group block is fixed in #25527.

@github-actions
Copy link

Size Change: +70 B (0%)

Total Size: 1.2 MB

Filename Size Change
build/block-editor/style-rtl.css 11.1 kB -2 B (0%)
build/block-editor/style.css 11.1 kB -1 B
build/block-library/editor-rtl.css 8.62 kB +37 B (0%)
build/block-library/editor.css 8.62 kB +37 B (0%)
build/block-library/index.js 135 kB -1 B
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.52 kB 0 B
build/api-fetch/index.js 3.34 kB 0 B
build/autop/index.js 2.72 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/index.js 8.41 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-editor/index.js 128 kB 0 B
build/block-library/style-rtl.css 7.6 kB 0 B
build/block-library/style.css 7.59 kB 0 B
build/block-library/theme-rtl.css 741 B 0 B
build/block-library/theme.css 741 B 0 B
build/block-serialization-default-parser/index.js 1.77 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/blocks/index.js 47.5 kB 0 B
build/components/index.js 202 kB 0 B
build/components/style-rtl.css 15.5 kB 0 B
build/components/style.css 15.5 kB 0 B
build/compose/index.js 9.42 kB 0 B
build/core-data/index.js 12 kB 0 B
build/data-controls/index.js 1.27 kB 0 B
build/data/index.js 8.43 kB 0 B
build/date/index.js 31.9 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 568 B 0 B
build/dom/index.js 4.42 kB 0 B
build/edit-navigation/index.js 10.4 kB 0 B
build/edit-navigation/style-rtl.css 868 B 0 B
build/edit-navigation/style.css 871 B 0 B
build/edit-post/index.js 306 kB 0 B
build/edit-post/style-rtl.css 6.24 kB 0 B
build/edit-post/style.css 6.23 kB 0 B
build/edit-site/index.js 19.6 kB 0 B
build/edit-site/style-rtl.css 3.3 kB 0 B
build/edit-site/style.css 3.3 kB 0 B
build/edit-widgets/index.js 17.6 kB 0 B
build/edit-widgets/style-rtl.css 2.8 kB 0 B
build/edit-widgets/style.css 2.8 kB 0 B
build/editor/editor-styles-rtl.css 492 B 0 B
build/editor/editor-styles.css 493 B 0 B
build/editor/index.js 45.3 kB 0 B
build/editor/style-rtl.css 3.8 kB 0 B
build/editor/style.css 3.8 kB 0 B
build/element/index.js 4.45 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/index.js 7.49 kB 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 1.74 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.54 kB 0 B
build/is-shallow-equal/index.js 711 B 0 B
build/keyboard-shortcuts/index.js 2.39 kB 0 B
build/keycodes/index.js 1.85 kB 0 B
build/list-reusable-blocks/index.js 3.02 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/media-utils/index.js 5.12 kB 0 B
build/notices/index.js 1.69 kB 0 B
build/nux/index.js 3.27 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.js 2.44 kB 0 B
build/primitives/index.js 1.34 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/redux-routine/index.js 2.85 kB 0 B
build/rich-text/index.js 13.7 kB 0 B
build/server-side-render/index.js 2.6 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.24 kB 0 B
build/url/index.js 4.06 kB 0 B
build/viewport/index.js 1.74 kB 0 B
build/warning/index.js 1.13 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@stokesman
Copy link
Contributor

This is rad! Thanks for picking it up Joen.

I suggest you add that this fixes #18906. Also while seemingly fixes #24460, that issue (despite its title) is more general and applies to any blocks using RangeControl.

@jasmussen
Copy link
Contributor Author

Thanks so much. I'm out for the day but I'll be back on this tomorrow and hopefully pairing with @talldan on a separate/additional range control fix that only validates/corrects the minimum value once focus is outside of the input field.

@stokesman
Copy link
Contributor

range control fix that only validates/corrects the minimum value once focus is outside of the input field

Hmm... sounds awfully familiar #25131 😉

@jasmussen
Copy link
Contributor Author

:mindblown:

CC @talldan

@jasmussen
Copy link
Contributor Author

Awesome, I've rephrased the body text to state the issue it fixes and only suggest it mitigates the other one.

I've restarted the tests on this one, it looks like they should pass. So it seems like the next step is just to get a review for this one and hopefully land it. I'll take a look at reviewing #25131 next.

@talldan talldan added the [Block] Spacer Affects the Spacer Block label Sep 24, 2020
Copy link
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working really well in my testing. The spacer is still very easy to select.

The only thing I notice that could be improved still is that it's a little difficult to get the block's border to show in navigation mode, which makes selecting if feel difficult (even though the click area is bigger than the border portrays):
selectmodespacer

I think we should give this a go though and try to improve that separately. Great work @jasmussen and @stokesman and anyone else who has taken time to iterate on this, I think this will make a lot of people happy!

@talldan talldan merged commit 73d8a36 into master Sep 24, 2020
@talldan talldan deleted the try/alt-spacer-fix branch September 24, 2020 02:27
@github-actions github-actions bot added this to the Gutenberg 9.1 milestone Sep 24, 2020
@talldan talldan changed the title Try: Alternate 1px spacer fix. Reduce minimum spacer height to 1px, while still retaining clickable area Sep 24, 2020
@Sven74Muc
Copy link

When to expect this in the Gutenberg plugin for testing?

@jasmussen
Copy link
Contributor Author

Version 9.1 I'd think.

@jasmussen
Copy link
Contributor Author

@youknowriad After merging this I'm seeing some block validation issues with existing spacer blocks :( — did I do something wrong here? Do I need to to revert?

@youknowriad
Copy link
Contributor

This PR doesn't have any impact on block vallidation, it's probably something else.

@Sven74Muc
Copy link

Working well, but with one limitaion:

  1. I add a spacer and want to adjust the hight with the arrows... not working.
  2. Shifting the circle is working
  3. Typing in the size is working
  4. After I have changed the size through one of the other methodes cliccking on the up and dow arrows is working
  5. Clicking on another block and than back in the spaer block... arrows are not working
  6. After I have changed the size through one of the other methodes clicking on the up and dow arrows is working

@stokesman
Copy link
Contributor

stokesman commented Sep 30, 2020

@Sven74Muc, when you refer to the up and down arrows, I'm not sure if you mean the keyboard keys or the little arrow buttons in the input. Will you clarify that? Okay, must be the little arrow buttons in the input since you wrote: "clicking".

I've been unable to reproduce the problem so far. What browser are you experiencing this with?

@Sven74Muc
Copy link

Yes, I mean the little arrow buttons.
Using the latest Firefox browser on Win10.

@Sven74Muc
Copy link

I switched on the troubleshoot mode... disabled all plugins and switched to the twenty twenty theme >>> working
I enabled the Gutenberg plugin >>> not working

@jasmussen
Copy link
Contributor Author

@Sven74Muc Thanks for the report. I can't reproduce, though, even in Firefox. Do you have any additional steps to reproduce? It also works for me in TwentyTwenty
firefox

@stokesman
Copy link
Contributor

Thank you @Sven74Muc. I can confirm the issue. Easily reproduced in Firefox by clicking on the little arrows anytime the input does not already have focus. Other browsers focus the input at the same time the arrows are clicked.

Definitely not an issue with this PR. I'll try making a fix since it relates to changes from #25609.

@Sven74Muc
Copy link

Sven74Muc commented Sep 30, 2020

Great, thanks @stokesman
Sorry if I placed it on the wrong place... It came with the 9.1 update and the issue is with the sizing of the spacer. I'm not a programmer at all... so couldn't see that the issue is comming somewhere else. However, thanks for looking into it!!

@Sven74Muc
Copy link

Just wondering where you have the arrows... I have them only on the right sidebar, not directly at the block

@Sven74Muc
Copy link

Ah, got it.... I mean different arrows, please see here: https://dlgo.de/30-09-_2020_20-15-09.mp4

@stokesman
Copy link
Contributor

@Sven74Muc, no worries. When I mentioned that it's not an issue with this PR it was to clarify for other readers. I've drafted a PR that fixes the issue. I'd guess this will be resolved by the next release but I'm not one to say.

@Sven74Muc
Copy link

Thanks @stokesman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Spacer Affects the Spacer Block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spacer Block: cannot adjust height to less than 20px
5 participants