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

Spacer block: use same min value resizable box and controls, remove max limit #39577

Merged
merged 7 commits into from
Mar 22, 2022

Conversation

ciampo
Copy link
Contributor

@ciampo ciampo commented Mar 18, 2022

What?

This PR tweaks the interactive resizable box and the sidebar controls used to tweaks the Spacer block. With the changes in this PR, both the resizable box (used to resize the spacer by dragging its handle) and the sidebar controls have:

  • a shared min value of 0
  • no max value

This is true for both the horizontal and the vertical orientations.

Why?

As flagged by @aaronrobertshaw in #39513 (review), currently the controls in the sidebar and the interactive resizable box operate with different minimum and maximum allowed values.

How?

The main reason for adopting a minimum value of 0 and not having a maximum value is that it would be almost impossible to have a numeric min/max value that would translate fairly to all possible units available through UnitControl

Testing Instructions

  • insert a spacer block, play around by resizing it both by dragging the handle and by changing the value in the controls in the sidebar
  • both methods of interacting with the spacer should avoid its width to go negative, but there shouldn't be any limit to how big the spacer can grow.

Screenshots or screencast

spacer-block.mp4

@ciampo ciampo added [Type] Enhancement A suggestion for improvement. [Package] Block library /packages/block-library [Block] Spacer Affects the Spacer Block labels Mar 18, 2022
@ciampo ciampo requested a review from ajitbohra as a code owner March 18, 2022 11:18
@ciampo ciampo self-assigned this Mar 18, 2022
@github-actions
Copy link

github-actions bot commented Mar 18, 2022

Size Change: -11 B (0%)

Total Size: 1.21 MB

Filename Size Change
build/block-library/index.min.js 169 kB -11 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 993 B
build/admin-manifest/index.min.js 1.24 kB
build/annotations/index.min.js 2.77 kB
build/api-fetch/index.min.js 2.27 kB
build/autop/index.min.js 2.15 kB
build/blob/index.min.js 487 B
build/block-directory/index.min.js 6.49 kB
build/block-directory/style-rtl.css 1.01 kB
build/block-directory/style.css 1.01 kB
build/block-editor/default-editor-styles-rtl.css 378 B
build/block-editor/default-editor-styles.css 378 B
build/block-editor/index.min.js 146 kB
build/block-editor/style-rtl.css 15.1 kB
build/block-editor/style.css 15.1 kB
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 65 B
build/block-library/blocks/archives/style.css 65 B
build/block-library/blocks/audio/editor-rtl.css 150 B
build/block-library/blocks/audio/editor.css 150 B
build/block-library/blocks/audio/style-rtl.css 111 B
build/block-library/blocks/audio/style.css 111 B
build/block-library/blocks/audio/theme-rtl.css 125 B
build/block-library/blocks/audio/theme.css 125 B
build/block-library/blocks/block/editor-rtl.css 161 B
build/block-library/blocks/block/editor.css 161 B
build/block-library/blocks/button/editor-rtl.css 445 B
build/block-library/blocks/button/editor.css 445 B
build/block-library/blocks/button/style-rtl.css 560 B
build/block-library/blocks/button/style.css 560 B
build/block-library/blocks/buttons/editor-rtl.css 292 B
build/block-library/blocks/buttons/editor.css 292 B
build/block-library/blocks/buttons/style-rtl.css 275 B
build/block-library/blocks/buttons/style.css 275 B
build/block-library/blocks/calendar/style-rtl.css 207 B
build/block-library/blocks/calendar/style.css 207 B
build/block-library/blocks/categories/editor-rtl.css 84 B
build/block-library/blocks/categories/editor.css 83 B
build/block-library/blocks/categories/style-rtl.css 79 B
build/block-library/blocks/categories/style.css 79 B
build/block-library/blocks/code/style-rtl.css 103 B
build/block-library/blocks/code/style.css 103 B
build/block-library/blocks/code/theme-rtl.css 124 B
build/block-library/blocks/code/theme.css 124 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 406 B
build/block-library/blocks/columns/style.css 406 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 125 B
build/block-library/blocks/comment-author-avatar/editor.css 125 B
build/block-library/blocks/comment-template/style-rtl.css 127 B
build/block-library/blocks/comment-template/style.css 127 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-query-loop/editor-rtl.css 95 B
build/block-library/blocks/comments-query-loop/editor.css 95 B
build/block-library/blocks/cover/editor-rtl.css 546 B
build/block-library/blocks/cover/editor.css 547 B
build/block-library/blocks/cover/style-rtl.css 1.56 kB
build/block-library/blocks/cover/style.css 1.56 kB
build/block-library/blocks/embed/editor-rtl.css 293 B
build/block-library/blocks/embed/editor.css 293 B
build/block-library/blocks/embed/style-rtl.css 417 B
build/block-library/blocks/embed/style.css 417 B
build/block-library/blocks/embed/theme-rtl.css 124 B
build/block-library/blocks/embed/theme.css 124 B
build/block-library/blocks/file/editor-rtl.css 300 B
build/block-library/blocks/file/editor.css 300 B
build/block-library/blocks/file/style-rtl.css 255 B
build/block-library/blocks/file/style.css 255 B
build/block-library/blocks/file/view.min.js 353 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB
build/block-library/blocks/freeform/editor.css 2.44 kB
build/block-library/blocks/gallery/editor-rtl.css 961 B
build/block-library/blocks/gallery/editor.css 964 B
build/block-library/blocks/gallery/style-rtl.css 1.51 kB
build/block-library/blocks/gallery/style.css 1.51 kB
build/block-library/blocks/gallery/theme-rtl.css 122 B
build/block-library/blocks/gallery/theme.css 122 B
build/block-library/blocks/group/editor-rtl.css 159 B
build/block-library/blocks/group/editor.css 159 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 114 B
build/block-library/blocks/heading/style.css 114 B
build/block-library/blocks/html/editor-rtl.css 332 B
build/block-library/blocks/html/editor.css 333 B
build/block-library/blocks/image/editor-rtl.css 731 B
build/block-library/blocks/image/editor.css 730 B
build/block-library/blocks/image/style-rtl.css 529 B
build/block-library/blocks/image/style.css 535 B
build/block-library/blocks/image/theme-rtl.css 124 B
build/block-library/blocks/image/theme.css 124 B
build/block-library/blocks/latest-comments/style-rtl.css 284 B
build/block-library/blocks/latest-comments/style.css 284 B
build/block-library/blocks/latest-posts/editor-rtl.css 199 B
build/block-library/blocks/latest-posts/editor.css 198 B
build/block-library/blocks/latest-posts/style-rtl.css 447 B
build/block-library/blocks/latest-posts/style.css 446 B
build/block-library/blocks/list/style-rtl.css 94 B
build/block-library/blocks/list/style.css 94 B
build/block-library/blocks/media-text/editor-rtl.css 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 493 B
build/block-library/blocks/media-text/style.css 490 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 708 B
build/block-library/blocks/navigation-link/editor.css 706 B
build/block-library/blocks/navigation-link/style-rtl.css 94 B
build/block-library/blocks/navigation-link/style.css 94 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 299 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation-submenu/view.min.js 375 B
build/block-library/blocks/navigation/editor-rtl.css 2.03 kB
build/block-library/blocks/navigation/editor.css 2.04 kB
build/block-library/blocks/navigation/style-rtl.css 1.89 kB
build/block-library/blocks/navigation/style.css 1.88 kB
build/block-library/blocks/navigation/view.min.js 2.85 kB
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 363 B
build/block-library/blocks/page-list/editor.css 363 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B
build/block-library/blocks/paragraph/editor.css 157 B
build/block-library/blocks/paragraph/style-rtl.css 273 B
build/block-library/blocks/paragraph/style.css 273 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/style-rtl.css 446 B
build/block-library/blocks/post-comments-form/style.css 446 B
build/block-library/blocks/post-comments/style-rtl.css 521 B
build/block-library/blocks/post-comments/style.css 521 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B
build/block-library/blocks/post-excerpt/editor.css 73 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B
build/block-library/blocks/post-excerpt/style.css 69 B
build/block-library/blocks/post-featured-image/editor-rtl.css 721 B
build/block-library/blocks/post-featured-image/editor.css 721 B
build/block-library/blocks/post-featured-image/style-rtl.css 153 B
build/block-library/blocks/post-featured-image/style.css 153 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 323 B
build/block-library/blocks/post-template/style.css 323 B
build/block-library/blocks/post-terms/style-rtl.css 73 B
build/block-library/blocks/post-terms/style.css 73 B
build/block-library/blocks/post-title/style-rtl.css 80 B
build/block-library/blocks/post-title/style.css 80 B
build/block-library/blocks/preformatted/style-rtl.css 103 B
build/block-library/blocks/preformatted/style.css 103 B
build/block-library/blocks/pullquote/editor-rtl.css 198 B
build/block-library/blocks/pullquote/editor.css 198 B
build/block-library/blocks/pullquote/style-rtl.css 370 B
build/block-library/blocks/pullquote/style.css 370 B
build/block-library/blocks/pullquote/theme-rtl.css 167 B
build/block-library/blocks/pullquote/theme.css 167 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 234 B
build/block-library/blocks/query-pagination/style.css 231 B
build/block-library/blocks/query/editor-rtl.css 131 B
build/block-library/blocks/query/editor.css 132 B
build/block-library/blocks/quote/style-rtl.css 201 B
build/block-library/blocks/quote/style.css 201 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/read-more/style-rtl.css 132 B
build/block-library/blocks/read-more/style.css 132 B
build/block-library/blocks/rss/editor-rtl.css 202 B
build/block-library/blocks/rss/editor.css 204 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 165 B
build/block-library/blocks/search/editor.css 165 B
build/block-library/blocks/search/style-rtl.css 397 B
build/block-library/blocks/search/style.css 398 B
build/block-library/blocks/search/theme-rtl.css 64 B
build/block-library/blocks/search/theme.css 64 B
build/block-library/blocks/separator/editor-rtl.css 140 B
build/block-library/blocks/separator/editor.css 140 B
build/block-library/blocks/separator/style-rtl.css 233 B
build/block-library/blocks/separator/style.css 233 B
build/block-library/blocks/separator/theme-rtl.css 194 B
build/block-library/blocks/separator/theme.css 194 B
build/block-library/blocks/shortcode/editor-rtl.css 474 B
build/block-library/blocks/shortcode/editor.css 474 B
build/block-library/blocks/site-logo/editor-rtl.css 759 B
build/block-library/blocks/site-logo/editor.css 759 B
build/block-library/blocks/site-logo/style-rtl.css 181 B
build/block-library/blocks/site-logo/style.css 181 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 84 B
build/block-library/blocks/site-title/editor.css 84 B
build/block-library/blocks/social-link/editor-rtl.css 177 B
build/block-library/blocks/social-link/editor.css 177 B
build/block-library/blocks/social-links/editor-rtl.css 674 B
build/block-library/blocks/social-links/editor.css 673 B
build/block-library/blocks/social-links/style-rtl.css 1.37 kB
build/block-library/blocks/social-links/style.css 1.36 kB
build/block-library/blocks/spacer/editor-rtl.css 332 B
build/block-library/blocks/spacer/editor.css 332 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 471 B
build/block-library/blocks/table/editor.css 472 B
build/block-library/blocks/table/style-rtl.css 481 B
build/block-library/blocks/table/style.css 481 B
build/block-library/blocks/table/theme-rtl.css 188 B
build/block-library/blocks/table/theme.css 188 B
build/block-library/blocks/tag-cloud/style-rtl.css 226 B
build/block-library/blocks/tag-cloud/style.css 227 B
build/block-library/blocks/template-part/editor-rtl.css 235 B
build/block-library/blocks/template-part/editor.css 235 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 87 B
build/block-library/blocks/verse/style.css 87 B
build/block-library/blocks/video/editor-rtl.css 571 B
build/block-library/blocks/video/editor.css 572 B
build/block-library/blocks/video/style-rtl.css 173 B
build/block-library/blocks/video/style.css 173 B
build/block-library/blocks/video/theme-rtl.css 124 B
build/block-library/blocks/video/theme.css 124 B
build/block-library/common-rtl.css 934 B
build/block-library/common.css 932 B
build/block-library/editor-rtl.css 9.98 kB
build/block-library/editor.css 9.98 kB
build/block-library/reset-rtl.css 474 B
build/block-library/reset.css 474 B
build/block-library/style-rtl.css 11.2 kB
build/block-library/style.css 11.2 kB
build/block-library/theme-rtl.css 689 B
build/block-library/theme.css 694 B
build/block-serialization-default-parser/index.min.js 1.12 kB
build/block-serialization-spec-parser/index.min.js 2.83 kB
build/blocks/index.min.js 46.8 kB
build/components/index.min.js 218 kB
build/components/style-rtl.css 15.6 kB
build/components/style.css 15.6 kB
build/compose/index.min.js 11.2 kB
build/core-data/index.min.js 14.3 kB
build/customize-widgets/index.min.js 11.2 kB
build/customize-widgets/style-rtl.css 1.39 kB
build/customize-widgets/style.css 1.39 kB
build/data-controls/index.min.js 663 B
build/data/index.min.js 8.19 kB
build/date/index.min.js 31.9 kB
build/deprecated/index.min.js 518 B
build/dom-ready/index.min.js 336 B
build/dom/index.min.js 4.53 kB
build/edit-navigation/index.min.js 16.1 kB
build/edit-navigation/style-rtl.css 4.04 kB
build/edit-navigation/style.css 4.05 kB
build/edit-post/classic-rtl.css 546 B
build/edit-post/classic.css 547 B
build/edit-post/index.min.js 29.8 kB
build/edit-post/style-rtl.css 7.07 kB
build/edit-post/style.css 7.07 kB
build/edit-site/index.min.js 44.9 kB
build/edit-site/style-rtl.css 7.44 kB
build/edit-site/style.css 7.42 kB
build/edit-widgets/index.min.js 16.5 kB
build/edit-widgets/style-rtl.css 4.39 kB
build/edit-widgets/style.css 4.39 kB
build/editor/index.min.js 38.4 kB
build/editor/style-rtl.css 3.71 kB
build/editor/style.css 3.71 kB
build/element/index.min.js 4.29 kB
build/escape-html/index.min.js 548 B
build/format-library/index.min.js 6.62 kB
build/format-library/style-rtl.css 571 B
build/format-library/style.css 571 B
build/hooks/index.min.js 1.66 kB
build/html-entities/index.min.js 454 B
build/i18n/index.min.js 3.79 kB
build/is-shallow-equal/index.min.js 535 B
build/keyboard-shortcuts/index.min.js 1.83 kB
build/keycodes/index.min.js 1.41 kB
build/list-reusable-blocks/index.min.js 1.75 kB
build/list-reusable-blocks/style-rtl.css 838 B
build/list-reusable-blocks/style.css 838 B
build/media-utils/index.min.js 2.94 kB
build/notices/index.min.js 957 B
build/nux/index.min.js 2.12 kB
build/nux/style-rtl.css 751 B
build/nux/style.css 749 B
build/plugins/index.min.js 1.98 kB
build/preferences/index.min.js 1.2 kB
build/primitives/index.min.js 949 B
build/priority-queue/index.min.js 611 B
build/react-i18n/index.min.js 704 B
build/react-refresh-entry/index.min.js 8.44 kB
build/react-refresh-runtime/index.min.js 7.31 kB
build/redux-routine/index.min.js 2.69 kB
build/reusable-blocks/index.min.js 2.24 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 11.1 kB
build/server-side-render/index.min.js 1.61 kB
build/shortcode/index.min.js 1.52 kB
build/token-list/index.min.js 668 B
build/url/index.min.js 1.99 kB
build/vendors/react-dom.min.js 38.5 kB
build/vendors/react.min.js 4.34 kB
build/viewport/index.min.js 1.08 kB
build/warning/index.min.js 280 B
build/widgets/index.min.js 7.21 kB
build/widgets/style-rtl.css 1.16 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.07 kB

compressed-size-action

@ciampo
Copy link
Contributor Author

ciampo commented Mar 18, 2022

Please keep 1 as min_spacer_size. When dimensions need to be precise, from 1 to 10 in Spacer block is necessary, since many blocks don't have margin (, padding, gap, ...) controls.

In the light of the above, I decided to have a separate set of min/max values for the spacer in horizontal and vertical configurations. As of now, I've chosen the same values that were already used previously:

  • Horizontal spacer: minimum width of 1. maximum width of 500
  • Vertical spacer: minimum width of 10, maximum width of 500

I also realised that the solution that I'm proposing is not currently a good one because, while we can assume that these quantities will always refer to px when resizing the spacer via its canvas drag handle, we can't make the same assumption for UnitControl, where the user can pick a few different units. In that case, it doesn't make sense to set the same min/max values across all units.

My proposed solution is:

  • set a common minimum value of 0, applied across all units and types of interactions (dragging and sidebar controls)
  • for the maximum value:
    • one alternative is not to set a maximum value at all — it is already possible to set any values for the spacer's dimensions by using the sidebar controls, and so the only change that this option would introduce if the dimension limit while dragging the handle. This would be my recommendation.
    • alternatively, we would need come up with a set of meaningful maximum values for each unit. This can become quite complicated, because basically all units but px are somehow dynamic (e.g. rem and em change based on the font size, vh and vw changes based on the viewport size...) and so it would be basically impossible to have "equivalent" maximum values for each unit

What do folks think?

@andrewserong
Copy link
Contributor

Thanks for following up!

set a common minimum value of 0, applied across all units and types of interactions (dragging and sidebar controls)

A minimum of 0 makes sense to me, as we'll need to support values less than 1, e.g. 0.25em or 0.5rem, etc. Ideally, I think we'd have the same min/max for horizontal vs vertical spacers, unless there's a particular need to split them out?

one alternative is not to set a maximum value at all

That's a good question. I'm not sure if there was a particular decision behind the 500 maximum, but one argument in favour of keeping the maximum (at least for the resizable control) is to have a natural limit to how far someone can accidentally drag the control. If they've dragged it too far, then maybe having a limit makes it easier to snap / restore the setting to a desired value? E.g. at the moment, if I drag the control all the way to the bottom of the screen, it snaps back to a reasonably sized region at 500px which feels a bit nicer to me, but I'd be curious if there's anyone that has a use-case for a larger value?

2022-03-21 11 54 12

@ciampo
Copy link
Contributor Author

ciampo commented Mar 21, 2022

A minimum of 0 makes sense to me

Agreed!

Ideally, I think we'd have the same min/max for horizontal vs vertical spacers, unless there's a particular need to split them out?

I don't know the answer to this question. @jasmussen (and @stacimc who worked on this block), do you know of any reasons why we wouldn't use the same min/max for vertical and horizontal spacers?

E.g. at the moment, if I drag the control all the way to the bottom of the screen, it snaps back to a reasonably sized region at 500px which feels a bit nicer to me, but I'd be curious if there's anyone that has a use-case for a larger value?

I see the utility of a max value when dragging, although I see 2 aspects that need to be clarified:

  1. as mentioned previously, we wouldn't be able to apply 500 as the max value of UnitControl, since it would assume completely different meanings depending on the unit (500px vs 500rem vs 500vw etc...). If we want to keep the 500px limit when dragging, we'd need to either:
    • only use that limit when the spacer is dragged, and otherwise don't pass any max value to UnitControl. This is not far from the behavior that we have currently, where UnitControl and ResizableSpacer don't share the same max (and also mostly why this PR was opened in the first place, so sync those two components)
    • somehow come up with max values for each unit that are equivalent to 500px — although, as explained above, that's not an easy task since most of these values are dynamic. I also believe that this would cause even more confusion in the user.
  2. Regarding how this max value currently gets applied to ResizableSpacer — we currently allow the spacer to be resized to any size, and then we clamp/snap it back to its max of 500px when the user stops dragging. Alternatively, we could simply pass the minWidth / minHeight attributes, which would already apply the clamping as the user drags the spacer handle. Which behavior do you think is better? (clamp when resizing stops vs clamp as resizing happens)

@jasmussen
Copy link
Contributor

I don't know the answer to this question. @jasmussen (and @stacimc who worked on this block), do you know of any reasons why we wouldn't use the same min/max for vertical and horizontal spacers?

A few pieces to this one:

  • the min value so far has existed because if it becomes too small, the block is barely selectable in the UI.
  • horizontally, it seems more common to use block gap to space out items, which means we can use the spacer either for adaptive spacers (Spacer: Add toggle to behave as flexible spacer to take up available space (flex-grow) #38022) or just as a larger space. So we probably don't have to have a super small min value here.
  • in terms of max-widths/heights, I don't know if we do need a max when all works well. But I have occasionally encountered issues with scrolling and scaling of items in the canvas that caused weird things to happen (Site Editor / iframe: Occasional double scrollbar. #30055), so it's probably fine to keep it intact at least for the near future, just so you don't slip the mouse and end up with a 5000px wide spacer.

Not strong opinions, the above, and ultimately what works well works well, so feel free to go with something! Even if it means unifying on a single set of values across hoz and vert.

@ciampo
Copy link
Contributor Author

ciampo commented Mar 21, 2022

the min value so far has existed because if it becomes too small, the block is barely selectable in the UI.

This is a fair point, although I think it could be still ok because the block could be selected also via the block list (and tweaked via the controls in the sidebar).

Although we should probably explore a way to make "zero-sized" blocks easier to selected in the canvas.

So we probably don't have to have a super small min value here.

The problem with having any other values than 0 is the same explained for the max: it would be very difficult to share that min value between ResizableBox and UnitControl, since the meaning of a quantity can vary greatly depending on the unit (1px vs 1rem...).

in terms of max-widths/heights [...] it's probably fine to keep it intact at least for the near future

What you say sounds sensible, although it means that we won't be able to "sync" ResizableBox and UnitControl.


Overall, it looks like it's almost impossible to make changes to how the max value is applied while editing the Spacer block. The only change that could be potentially made if to set a min value of 0 across ResizableSpacer and UnitControl and for both horizontal and vertical configurations.

Otherwise I'm also happy to close this PR and leave the block as-is for now.

@jasmussen
Copy link
Contributor

Seems fine to move ahead in that direction, zero and no max, if that's what's needed.

Although we should probably explore a way to make "zero-sized" blocks easier to selected in the canvas.

Now that I think of it, I think we do have a pseudo element there to enable zero height blocks being selected:
Screenshot 2022-03-21 at 11 25 39

@ciampo ciampo force-pushed the fix/spacer-block-align-min-values branch from 15a81af to 6ae3da6 Compare March 21, 2022 13:43
@ciampo
Copy link
Contributor Author

ciampo commented Mar 21, 2022

Alright, I went ahead and pushed some changes:

  • shared min value of 0 across the board (horizontal/vertical, ResizableSpacer and UnitControl)
  • removed the max value

This is the resulting experience:

spacer-block.mp4

Let me know how it feels, happy to tweak further!

@jasmussen
Copy link
Contributor

Seems okay to try.

@ciampo
Copy link
Contributor Author

ciampo commented Mar 21, 2022

Alright, let's wait to see what other folks think too and potentially merge — thank you @jasmussen !

@ciampo ciampo changed the title Spacer block: use same min/max sizes for resizable box and controls Spacer block: use same min value resizable box and controls, remove max limit Mar 21, 2022
Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

Thanks for the follow-up @ciampo and the feedback @jasmussen! This is testing nicely for me, and fits my personal preferences for using the spacer in both horizontal and vertical arrangements. Particularly now that #39531 has been merged, it feels easier to use with smaller values (like 0.5em) now 👍

Looks good to try, to me! 🎉

@andrewserong
Copy link
Contributor

I've opened up a separate PR (#39623) to look at ensuring that the tooltip text for the ResizableBox stays on a single line (I noticed it overflowed at narrower widths when the Spacer is running in a horizontal configuration).

@ciampo ciampo merged commit c67d146 into trunk Mar 22, 2022
@ciampo ciampo deleted the fix/spacer-block-align-min-values branch March 22, 2022 08:27
@github-actions github-actions bot added this to the Gutenberg 12.9 milestone Mar 22, 2022
jostnes pushed a commit to jostnes/gutenberg that referenced this pull request Mar 23, 2022
… `max` limit (WordPress#39577)

* Spacer block: update min size from 1 to 10

* Spacer: apply min/max sizes to ResizableSpacer

* Spacer block: apply min/max sizes to controls

* Separate width/height constraints for horizontal or vertical configurations

* Set `min` to `0`

* Remove `max` value

* Unify vertical/horizontal min sizes back into one variable
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 [Package] Block library /packages/block-library [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants