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

Separator Block: Add top and bottom margins without resizable box #29363

Closed

Conversation

aaronrobertshaw
Copy link
Contributor

@aaronrobertshaw aaronrobertshaw commented Feb 26, 2021

Description

This adds the ability to set top and bottom margins on the separator block.

How has this been tested?

Manually.

Testing Instructions

Web
  1. Checkout this PR
  2. Add a separator block to a post and select it
  3. Adjust the top and bottom margins including units via the sidebar controls
  4. Ensure block updates visually in editor and frontend
Native
  1. Start up native simulator
  2. Add a separator block, select it and open its controls
  3. Adjust top and bottom margins including units
  4. Confirm block updates visually as expected

Screenshots

Web Native
Separator-Web Separator-Native

Types of changes

New Feature

Next Steps

Update controls for Native.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@aaronrobertshaw aaronrobertshaw added [Type] Enhancement A suggestion for improvement. [Block] Separator Affects the Separator Block labels Feb 26, 2021
@aaronrobertshaw aaronrobertshaw self-assigned this Feb 26, 2021
@github-actions
Copy link

github-actions bot commented Feb 26, 2021

Size Change: +24 kB (+2%)

Total Size: 1.41 MB

Filename Size Change
build/annotations/index.js 3.78 kB -13 B (0%)
build/api-fetch/index.js 3.4 kB -7 B (0%)
build/autop/index.js 2.82 kB -17 B (-1%)
build/blob/index.js 664 B -1 B (0%)
build/block-directory/index.js 8.62 kB -478 B (-5%)
build/block-directory/style-rtl.css 1 kB -6 B (-1%)
build/block-directory/style.css 1.01 kB -5 B (0%)
build/block-editor/index.js 127 kB +2.15 kB (+2%)
build/block-editor/style-rtl.css 12.4 kB +281 B (+2%)
build/block-editor/style.css 12.4 kB +283 B (+2%)
build/block-library/blocks/audio/style-rtl.css 112 B +9 B (+9%) 🔍
build/block-library/blocks/audio/style.css 112 B +9 B (+9%) 🔍
build/block-library/blocks/cover/editor-rtl.css 605 B +215 B (+55%) 🆘
build/block-library/blocks/cover/editor.css 605 B +216 B (+56%) 🆘
build/block-library/blocks/cover/style-rtl.css 1.24 kB -10 B (-1%)
build/block-library/blocks/cover/style.css 1.24 kB -10 B (-1%)
build/block-library/blocks/embed/style-rtl.css 401 B +5 B (+1%)
build/block-library/blocks/embed/style.css 400 B +5 B (+1%)
build/block-library/blocks/freeform/editor-rtl.css 2.46 kB +7 B (0%)
build/block-library/blocks/freeform/editor.css 2.46 kB +7 B (0%)
build/block-library/blocks/gallery/editor-rtl.css 704 B +15 B (+2%)
build/block-library/blocks/gallery/editor.css 705 B +15 B (+2%)
build/block-library/blocks/gallery/style-rtl.css 1.11 kB +40 B (+4%)
build/block-library/blocks/gallery/style.css 1.1 kB +40 B (+4%)
build/block-library/blocks/group/editor-rtl.css 160 B -158 B (-50%) 🏆
build/block-library/blocks/group/editor.css 160 B -157 B (-50%) 🏆
build/block-library/blocks/image/style-rtl.css 476 B -1 B (0%)
build/block-library/blocks/navigation-link/editor-rtl.css 626 B -55 B (-8%)
build/block-library/blocks/navigation-link/editor.css 627 B -56 B (-8%)
build/block-library/blocks/navigation-link/style-rtl.css 685 B -9 B (-1%)
build/block-library/blocks/navigation-link/style.css 682 B -10 B (-1%)
build/block-library/blocks/navigation/editor-rtl.css 1.11 kB -228 B (-17%) 👏
build/block-library/blocks/navigation/editor.css 1.11 kB -223 B (-17%) 👏
build/block-library/blocks/navigation/style-rtl.css 204 B -9 B (-4%)
build/block-library/blocks/navigation/style.css 205 B -9 B (-4%)
build/block-library/blocks/page-list/editor-rtl.css 170 B -44 B (-21%) 🎉
build/block-library/blocks/page-list/editor.css 170 B -44 B (-21%) 🎉
build/block-library/blocks/page-list/style-rtl.css 537 B +10 B (+2%)
build/block-library/blocks/page-list/style.css 536 B +10 B (+2%)
build/block-library/blocks/paragraph/editor-rtl.css 157 B +48 B (+44%) 🚨
build/block-library/blocks/paragraph/editor.css 157 B +48 B (+44%) 🚨
build/block-library/blocks/paragraph/style-rtl.css 247 B -41 B (-14%) 👏
build/block-library/blocks/paragraph/style.css 248 B -41 B (-14%) 👏
build/block-library/blocks/pullquote/style-rtl.css 318 B +2 B (+1%)
build/block-library/blocks/pullquote/style.css 318 B +2 B (+1%)
build/block-library/blocks/query-loop/editor-rtl.css 83 B -7 B (-8%)
build/block-library/blocks/query-loop/editor.css 82 B -7 B (-8%)
build/block-library/blocks/query/editor-rtl.css 795 B -19 B (-2%)
build/block-library/blocks/query/editor.css 794 B -18 B (-2%)
build/block-library/blocks/separator/editor-rtl.css 79 B -20 B (-20%) 🎉
build/block-library/blocks/separator/editor.css 79 B -20 B (-20%) 🎉
build/block-library/blocks/shortcode/editor-rtl.css 512 B +8 B (+2%)
build/block-library/blocks/shortcode/editor.css 512 B +8 B (+2%)
build/block-library/blocks/social-links/editor-rtl.css 776 B +80 B (+11%) ⚠️
build/block-library/blocks/social-links/editor.css 776 B +80 B (+11%) ⚠️
build/block-library/blocks/social-links/style-rtl.css 1.32 kB +9 B (+1%)
build/block-library/blocks/social-links/style.css 1.33 kB +9 B (+1%)
build/block-library/blocks/spacer/editor-rtl.css 317 B +15 B (+5%) 🔍
build/block-library/blocks/spacer/editor.css 317 B +15 B (+5%) 🔍
build/block-library/blocks/subhead/editor-rtl.css 0 B -99 B (removed) 🏆
build/block-library/blocks/subhead/editor.css 0 B -99 B (removed) 🏆
build/block-library/blocks/subhead/style-rtl.css 0 B -80 B (removed) 🏆
build/block-library/blocks/subhead/style.css 0 B -80 B (removed) 🏆
build/block-library/blocks/table/style-rtl.css 402 B +12 B (+3%)
build/block-library/blocks/table/style.css 402 B +12 B (+3%)
build/block-library/blocks/template-part/editor-rtl.css 552 B -5 B (-1%)
build/block-library/blocks/template-part/editor.css 551 B -5 B (-1%)
build/block-library/blocks/verse/editor-rtl.css 50 B -12 B (-19%) 👏
build/block-library/blocks/verse/editor.css 50 B -12 B (-19%) 👏
build/block-library/blocks/video/style-rtl.css 187 B -6 B (-3%)
build/block-library/blocks/video/style.css 187 B -6 B (-3%)
build/block-library/common-rtl.css 1.1 kB +18 B (+2%)
build/block-library/common.css 1.1 kB +20 B (+2%)
build/block-library/editor-rtl.css 9.46 kB -59 B (-1%)
build/block-library/editor.css 9.47 kB -45 B (0%)
build/block-library/index.js 148 kB +98 B (0%)
build/block-library/style-rtl.css 8.88 kB +36 B (0%)
build/block-library/style.css 8.89 kB +32 B (0%)
build/block-library/theme-rtl.css 700 B -36 B (-5%)
build/block-library/theme.css 701 B -35 B (-5%)
build/block-serialization-default-parser/index.js 1.87 kB -9 B (0%)
build/blocks/index.js 48.3 kB -8 B (0%)
build/components/index.js 284 kB +11.5 kB (+4%)
build/components/style-rtl.css 16.2 kB +694 B (+4%)
build/components/style.css 16.2 kB +697 B (+4%)
build/compose/index.js 11.2 kB +68 B (+1%)
build/core-data/index.js 16.7 kB -49 B (0%)
build/customize-widgets/index.js 5.99 kB +1.91 kB (+47%) 🚨
build/customize-widgets/style-rtl.css 378 B +210 B (+125%) 🆘
build/customize-widgets/style.css 379 B +211 B (+126%) 🆘
build/data-controls/index.js 830 B -1 B (0%)
build/data/index.js 8.87 kB +3 B (0%)
build/deprecated/index.js 787 B +18 B (+2%)
build/dom-ready/index.js 577 B +1 B (0%)
build/dom/index.js 4.97 kB +15 B (0%)
build/edit-navigation/index.js 16.4 kB +5.42 kB (+49%) 🚨
build/edit-navigation/style-rtl.css 2.48 kB +1.22 kB (+97%) 🆘
build/edit-navigation/style.css 2.48 kB +1.22 kB (+98%) 🆘
build/edit-post/index.js 307 kB -309 B (0%)
build/edit-post/style-rtl.css 7.05 kB +240 B (+4%)
build/edit-post/style.css 7.04 kB +242 B (+4%)
build/edit-site/index.js 27.1 kB +724 B (+3%)
build/edit-site/style-rtl.css 4.51 kB +94 B (+2%)
build/edit-site/style.css 4.5 kB +91 B (+2%)
build/edit-widgets/index.js 20.1 kB -66 B (0%)
build/edit-widgets/style-rtl.css 3.14 kB -62 B (-2%)
build/edit-widgets/style.css 3.14 kB -61 B (-2%)
build/editor/editor-styles-rtl.css 0 B -543 B (removed) 🏆
build/editor/editor-styles.css 0 B -545 B (removed) 🏆
build/editor/index.js 41.9 kB -257 B (-1%)
build/editor/style-rtl.css 3.9 kB +4 B (0%)
build/editor/style.css 3.9 kB +4 B (0%)
build/element/index.js 4.61 kB -10 B (0%)
build/format-library/index.js 6.75 kB -18 B (0%)
build/hooks/index.js 2.28 kB -2 B (0%)
build/i18n/index.js 4.01 kB -4 B (0%)
build/is-shallow-equal/index.js 699 B +1 B (0%)
build/keyboard-shortcuts/index.js 2.53 kB -14 B (-1%)
build/keycodes/index.js 1.95 kB -7 B (0%)
build/list-reusable-blocks/index.js 3.15 kB +3 B (0%)
build/media-utils/index.js 5.34 kB -17 B (0%)
build/notices/index.js 1.85 kB -4 B (0%)
build/nux/index.js 3.4 kB -11 B (0%)
build/plugins/index.js 2.89 kB +286 B (+11%) ⚠️
build/primitives/index.js 1.42 kB -6 B (0%)
build/react-i18n/index.js 1.45 kB +2 B (0%)
build/redux-routine/index.js 2.83 kB -1 B (0%)
build/reusable-blocks/index.js 3.78 kB -24 B (-1%)
build/rich-text/index.js 13.3 kB -179 B (-1%)
build/server-side-render/index.js 2.58 kB -237 B (-8%)
build/url/index.js 3.02 kB -1 B (0%)
build/viewport/index.js 1.86 kB +1 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/block-library/blocks/archives/editor-rtl.css 61 B 0 B
build/block-library/blocks/archives/editor.css 60 B 0 B
build/block-library/blocks/audio/editor-rtl.css 58 B 0 B
build/block-library/blocks/audio/editor.css 58 B 0 B
build/block-library/blocks/block/editor-rtl.css 161 B 0 B
build/block-library/blocks/block/editor.css 161 B 0 B
build/block-library/blocks/button/editor-rtl.css 475 B 0 B
build/block-library/blocks/button/editor.css 474 B 0 B
build/block-library/blocks/button/style-rtl.css 479 B 0 B
build/block-library/blocks/button/style.css 479 B 0 B
build/block-library/blocks/buttons/editor-rtl.css 315 B 0 B
build/block-library/blocks/buttons/editor.css 315 B 0 B
build/block-library/blocks/buttons/style-rtl.css 364 B 0 B
build/block-library/blocks/buttons/style.css 363 B 0 B
build/block-library/blocks/calendar/style-rtl.css 208 B 0 B
build/block-library/blocks/calendar/style.css 208 B 0 B
build/block-library/blocks/categories/editor-rtl.css 84 B 0 B
build/block-library/blocks/categories/editor.css 83 B 0 B
build/block-library/blocks/categories/style-rtl.css 79 B 0 B
build/block-library/blocks/categories/style.css 79 B 0 B
build/block-library/blocks/code/style-rtl.css 90 B 0 B
build/block-library/blocks/code/style.css 90 B 0 B
build/block-library/blocks/columns/editor-rtl.css 190 B 0 B
build/block-library/blocks/columns/editor.css 190 B 0 B
build/block-library/blocks/columns/style-rtl.css 421 B 0 B
build/block-library/blocks/columns/style.css 421 B 0 B
build/block-library/blocks/embed/editor-rtl.css 486 B 0 B
build/block-library/blocks/embed/editor.css 486 B 0 B
build/block-library/blocks/file/editor-rtl.css 199 B 0 B
build/block-library/blocks/file/editor.css 198 B 0 B
build/block-library/blocks/file/style-rtl.css 248 B 0 B
build/block-library/blocks/file/style.css 248 B 0 B
build/block-library/blocks/group/style-rtl.css 57 B 0 B
build/block-library/blocks/group/style.css 57 B 0 B
build/block-library/blocks/heading/editor-rtl.css 129 B 0 B
build/block-library/blocks/heading/editor.css 129 B 0 B
build/block-library/blocks/heading/style-rtl.css 76 B 0 B
build/block-library/blocks/heading/style.css 76 B 0 B
build/block-library/blocks/html/editor-rtl.css 281 B 0 B
build/block-library/blocks/html/editor.css 281 B 0 B
build/block-library/blocks/image/editor-rtl.css 717 B 0 B
build/block-library/blocks/image/editor.css 716 B 0 B
build/block-library/blocks/image/style.css 478 B 0 B
build/block-library/blocks/latest-comments/editor-rtl.css 159 B 0 B
build/block-library/blocks/latest-comments/editor.css 158 B 0 B
build/block-library/blocks/latest-comments/style-rtl.css 269 B 0 B
build/block-library/blocks/latest-comments/style.css 269 B 0 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B 0 B
build/block-library/blocks/latest-posts/editor.css 137 B 0 B
build/block-library/blocks/latest-posts/style-rtl.css 523 B 0 B
build/block-library/blocks/latest-posts/style.css 522 B 0 B
build/block-library/blocks/list/editor-rtl.css 65 B 0 B
build/block-library/blocks/list/editor.css 65 B 0 B
build/block-library/blocks/list/style-rtl.css 63 B 0 B
build/block-library/blocks/list/style.css 63 B 0 B
build/block-library/blocks/media-text/editor-rtl.css 191 B 0 B
build/block-library/blocks/media-text/editor.css 191 B 0 B
build/block-library/blocks/media-text/style-rtl.css 535 B 0 B
build/block-library/blocks/media-text/style.css 532 B 0 B
build/block-library/blocks/more/editor-rtl.css 434 B 0 B
build/block-library/blocks/more/editor.css 434 B 0 B
build/block-library/blocks/nextpage/editor-rtl.css 395 B 0 B
build/block-library/blocks/nextpage/editor.css 395 B 0 B
build/block-library/blocks/post-author/editor-rtl.css 209 B 0 B
build/block-library/blocks/post-author/editor.css 209 B 0 B
build/block-library/blocks/post-author/style-rtl.css 183 B 0 B
build/block-library/blocks/post-author/style.css 184 B 0 B
build/block-library/blocks/post-comments-form/style-rtl.css 250 B 0 B
build/block-library/blocks/post-comments-form/style.css 250 B 0 B
build/block-library/blocks/post-content/editor-rtl.css 139 B 0 B
build/block-library/blocks/post-content/editor.css 139 B 0 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B 0 B
build/block-library/blocks/post-excerpt/editor.css 73 B 0 B
build/block-library/blocks/post-featured-image/editor-rtl.css 338 B 0 B
build/block-library/blocks/post-featured-image/editor.css 338 B 0 B
build/block-library/blocks/post-featured-image/style-rtl.css 100 B 0 B
build/block-library/blocks/post-featured-image/style.css 100 B 0 B
build/block-library/blocks/preformatted/style-rtl.css 63 B 0 B
build/block-library/blocks/preformatted/style.css 63 B 0 B
build/block-library/blocks/pullquote/editor-rtl.css 183 B 0 B
build/block-library/blocks/pullquote/editor.css 183 B 0 B
build/block-library/blocks/query-loop/style-rtl.css 315 B 0 B
build/block-library/blocks/query-loop/style.css 317 B 0 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B 0 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B 0 B
build/block-library/blocks/query-pagination/editor-rtl.css 270 B 0 B
build/block-library/blocks/query-pagination/editor.css 262 B 0 B
build/block-library/blocks/query-pagination/style-rtl.css 168 B 0 B
build/block-library/blocks/query-pagination/style.css 168 B 0 B
build/block-library/blocks/query-title/editor-rtl.css 86 B 0 B
build/block-library/blocks/query-title/editor.css 86 B 0 B
build/block-library/blocks/quote/editor-rtl.css 61 B 0 B
build/block-library/blocks/quote/editor.css 61 B 0 B
build/block-library/blocks/quote/style-rtl.css 169 B 0 B
build/block-library/blocks/quote/style.css 169 B 0 B
build/block-library/blocks/rss/editor-rtl.css 201 B 0 B
build/block-library/blocks/rss/editor.css 202 B 0 B
build/block-library/blocks/rss/style-rtl.css 290 B 0 B
build/block-library/blocks/rss/style.css 290 B 0 B
build/block-library/blocks/search/editor-rtl.css 165 B 0 B
build/block-library/blocks/search/editor.css 165 B 0 B
build/block-library/blocks/search/style-rtl.css 342 B 0 B
build/block-library/blocks/search/style.css 344 B 0 B
build/block-library/blocks/separator/style-rtl.css 236 B 0 B
build/block-library/blocks/separator/style.css 236 B 0 B
build/block-library/blocks/site-logo/editor-rtl.css 201 B 0 B
build/block-library/blocks/site-logo/editor.css 201 B 0 B
build/block-library/blocks/site-logo/style-rtl.css 115 B 0 B
build/block-library/blocks/site-logo/style.css 115 B 0 B
build/block-library/blocks/social-link/editor-rtl.css 164 B 0 B
build/block-library/blocks/social-link/editor.css 165 B 0 B
build/block-library/blocks/spacer/style-rtl.css 48 B 0 B
build/block-library/blocks/spacer/style.css 48 B 0 B
build/block-library/blocks/table/editor-rtl.css 478 B 0 B
build/block-library/blocks/table/editor.css 478 B 0 B
build/block-library/blocks/tag-cloud/editor-rtl.css 118 B 0 B
build/block-library/blocks/tag-cloud/editor.css 118 B 0 B
build/block-library/blocks/tag-cloud/style-rtl.css 94 B 0 B
build/block-library/blocks/tag-cloud/style.css 94 B 0 B
build/block-library/blocks/term-description/editor-rtl.css 90 B 0 B
build/block-library/blocks/term-description/editor.css 90 B 0 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B 0 B
build/block-library/blocks/text-columns/editor.css 95 B 0 B
build/block-library/blocks/text-columns/style-rtl.css 166 B 0 B
build/block-library/blocks/text-columns/style.css 166 B 0 B
build/block-library/blocks/verse/style-rtl.css 87 B 0 B
build/block-library/blocks/verse/style.css 87 B 0 B
build/block-library/blocks/video/editor-rtl.css 504 B 0 B
build/block-library/blocks/video/editor.css 503 B 0 B
build/block-library/reset-rtl.css 374 B 0 B
build/block-library/reset.css 376 B 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/date/index.js 31.8 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/style-rtl.css 637 B 0 B
build/format-library/style.css 639 B 0 B
build/html-entities/index.js 622 B 0 B
build/list-reusable-blocks/style-rtl.css 629 B 0 B
build/list-reusable-blocks/style.css 628 B 0 B
build/nux/style-rtl.css 731 B 0 B
build/nux/style.css 727 B 0 B
build/priority-queue/index.js 791 B 0 B
build/reusable-blocks/style-rtl.css 225 B 0 B
build/reusable-blocks/style.css 225 B 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.22 kB 0 B

compressed-size-action

Base automatically changed from master to trunk March 1, 2021 15:46
@apeatling
Copy link
Contributor

Tested and this works for me. I think this approach makes the most sense in terms of a first iteration. However I think we'd need to follow up and replace this custom margin UI with the margins component (and allow it to disable certain margins so only top and bottom margins are editable).

@apeatling
Copy link
Contributor

apeatling commented Mar 18, 2021

@aaronrobertshaw Could this seamlessly switch to using the margins component in a future PR? My other thought is we spend the time on the margins component now to allow disabling of specific margins, so we can use it here before merging this.

@aaronrobertshaw
Copy link
Contributor Author

Could this seamlessly switch to using the margins component in a future PR?

Thanks for taking a look at this @apeatling.

Yes, I believe it will be a simple switch in the future to use the margins component. Especially if it used via the block support spacing feature which would store the margin values in the same style.spacing.margins.top and style.spacing.margins.bottom properties. It should only be a matter of replacing the controls, no migration of the block's attributes or markup.

My other thought is we spend the time on the margins component now to allow disabling of specific margins, so we can use it here before merging this.

I'm happy to take a look at the BoxControl and see how we might approach allowing opting out of particular sides. It would definitely be the cleanest approach for the UI.

Perhaps being able to opt out of particular sides would also help to offer margins via the spacing block support feature. It could then have left/right margin support disabled by default so they wouldn't interfere with block alignments.

@aaronrobertshaw aaronrobertshaw added the [Status] In Progress Tracking issues with work in progress label Mar 19, 2021
@aaronrobertshaw aaronrobertshaw changed the title Separator Block: Add top and bottom margins without resizable box [WIP] Separator Block: Add top and bottom margins without resizable box Mar 19, 2021
@aaronrobertshaw aaronrobertshaw marked this pull request as draft March 19, 2021 07:40
@aaronrobertshaw aaronrobertshaw added [Status] In Progress Tracking issues with work in progress and removed [Status] In Progress Tracking issues with work in progress labels Mar 22, 2021
@aaronrobertshaw
Copy link
Contributor Author

Created issue for errors thrown when mouse drag gesture is used on BoxControl's unit control fields. In the meantime, I've added the possible fix to this PR as an example. #30073

@aaronrobertshaw
Copy link
Contributor Author

Added box visualizer to web controls. Native still uses individual fields for top and bottom margins.

@aaronrobertshaw aaronrobertshaw changed the title [WIP] Separator Block: Add top and bottom margins without resizable box Separator Block: Add top and bottom margins without resizable box Mar 22, 2021
@aaronrobertshaw aaronrobertshaw removed the [Status] In Progress Tracking issues with work in progress label Mar 22, 2021
@aaronrobertshaw aaronrobertshaw marked this pull request as ready for review March 22, 2021 23:50
@andrewserong
Copy link
Contributor

Nice work @aaronrobertshaw, this is testing well for me manually in the web editor (I need to fix some thing on my laptop before I can get the iOS simulator running properly to test RN).

One thing I noticed in the UI for the BoxControl is that the BoxControlIcon currently highlights all four sides by default, but the control here is for just for the vertical margin. If we select the button to Unlink Sides, the icon will highlight just the selected side (e.g. either the top or the bottom side). Is it possible for us to have the default for this control highlight the top and bottom margins in the icon here, but leave the left and right sides greyed-out? Possibly by adding the isSideDisabled logic you've included in the input controls, to the icon component? Of course, it is pretty subtle!

All four sides are highlighted

image

One side is highlighted after selecting "Unlink sides"

image

@aaronrobertshaw
Copy link
Contributor Author

One thing I noticed in the UI for the BoxControl is that the BoxControlIcon currently highlights all four sides by default, but the control here is for just for the vertical margin.

Thanks @andrewserong, that would definitely be an improvement. I'll take a look at making it happen 👍

@aaronrobertshaw
Copy link
Contributor Author

The BoxControlIcon has been updated to reflect the enabled sides for the BoxControl

Screen Shot 2021-03-23 at 5 11 10 pm

@andrewserong
Copy link
Contributor

That's looking really good, thanks for updating the BoxControlIcon @aaronrobertshaw. I also tested the change in the React Native edit in the iOS simulator, and it's testing well for me.

I noticed one slight issue with the onChange behaviour for me in manual testing. While in the code it looks like the styling should update whenever we change a value within the input field, in practice it seems like when I update the field via keyboard entry, the styling only updates when I focus outside of the field. Here's an example:

separator-margin-sml

I couldn't quite work out why it wouldn't be updating onChange though, because it looks like that's what it should be doing 🤔

Other than that, this is looking good to me (though I must admit this is the first time I've looked at any of the React Native code!)

@aaronrobertshaw
Copy link
Contributor Author

Thanks @andrewserong for the thorough testing.

I couldn't quite work out why it wouldn't be updating onChange though, because it looks like that's what it should be doing 🤔

The onChange isn't actually being triggered on the BoxControl's UnitControl when typing within its input field. The BoxControl wraps the standard UnitControl to provide tooltips, hover gestures etc. It also sets the isPressEnterToChange prop for the UnitControl here.

If the isPressEnterToChange prop is removed then the input behaves as you expected. I'm not sure if we should change that as well or if there was a specific UX reason for it.

It's worth noting that pressing the up/down arrows on your keyboard to increment/decrement the value will immediately trigger the onChange.

@andrewserong
Copy link
Contributor

Thanks for getting to the bottom of that @aaronrobertshaw! It sounds like it's by design, then. I couldn't see if we've used the BoxControl component directly in any other blocks yet? I see the Cover block uses the BoxControlVisualizer from BoxControl, but then for the minimum height of the cover, it uses the UnitControl directly so it uses the onChange behaviour the same way as the custom font size on the paragraph or heading blocks.

I can see the value of preventing onChange until someone hits enter, so that the settings aren't flying around in the editor canvas until someone commits to it. But on the other hand, it's different behaviour to other similar input fields in the editor, which I think is why it felt like it wasn't working properly to me.

My personal preference would be to go for consistency with keyboard input behaviour across these sorts of inputs, but I think I'd lean toward leaving the discussion about the best UX for the BoxControl component itself to another PR, and leave it as-is in this one, if it doesn't seem like an issue for anyone else.

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.

Nice work @aaronrobertshaw, this is testing nicely for me in web and in the iOS simulator, and I think we can defer the BoxControl onChange UX to a separate issue / discussion.

It'd be good to get another pair of eyes from someone with more React Native experience than I have, but otherwise LGTM!

Copy link
Contributor

@apeatling apeatling 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 great on web and native for me, and I appreciate the time you've put in to use and update the BoxControl component. It feels really good.

@aaronrobertshaw
Copy link
Contributor Author

The changes within this PR and based off it have been split up into smaller chunks that are now already under review/feedback.

Closing this in favour of the collection of new PRs below:

#30606
#30607
#30608
#30609

@scruffian scruffian deleted the add/separator-margins-without-resizable-box branch April 27, 2022 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Separator Affects the Separator Block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants