-
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
Block Support: Set border style none when border width zero #32080
Conversation
Size Change: +160 B (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
I've updated this to also clear the border color selection and restore it if available when switching from zero to non-zero border width. The same as occurs for the border style. |
Nice! Retested and can confirm:
|
e4b68e8
to
41acd39
Compare
1c1dafe
to
e2703b0
Compare
e2703b0
to
0765a22
Compare
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.
LGTM
- Border styles persist in the editor when adjusting width from
0
ton
and back again (not between refreshes or switching between code and visual editors) - Frontend styles correspond to saved editor state.
Expand the border controls panel and select the solid border style option
Adjust the border width to a non-zero value, the solid border style button should remain on.
✅
Set the border width to 0. The border style buttons should all be deselected.
✅
Adjust the border width to a non-zero value again and the solid border style button should be reselected.
✅
Update the border width to 0 again, switch to the code editor view and confirm that the border style attribute is now set to none and the appropriate style is applied within the markup.
✅
Change the border style selection to "Dashed" or "Dotted" and repeat the process adjusting the width value.
✅
Confirm the block displays correctly on the frontend after saving.
✅
border-review-group.mp4
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.
This is testing nicely for me @aaronrobertshaw!
✅ Setting the width to 0 updates the inline style in the markup to set border-style: none;
✅ While adjusting the width in the UI, my previous settings are remembered. I noticed that if I go to the code view to check my markup and then switch back, my previous border style isn't remembered (since we're just using local React state rather than storing in the block's attributes). This seems fine to me — if I've switched out of editing the border, I don't expect it to remember my previous settings.
✅ The border style buttons render selected / vs deselected appropriately
✅ Works correctly with the dotted and dashed styles
✅ The block renders correctly on the front end
One other thing I noticed, which is separate to setting the border width to zero, is that if we have a non-zero value for border width, and de-select the border style, the border-width
property still gets included in the inline style. Should that be omitted in that case?
I think that's unrelated to this PR, so I don't think it's a blocker for moving this one forward.
Thank you for the reviews @ramonjd and @andrewserong.
With no border style selected it would be inheriting from the theme.json. In that case the adjustment of only the border width would still be valid. So in this instance I believe it should remain. |
Ah, great explanation. Thanks for the reminder! That sounds good to me, then. 👍 |
0765a22
to
9f4f238
Compare
This application of the border-style: none will only occur if border style support has been opted into for the block.
This clear border color selection when the border width is explicitly set to zero. When it is set back to a non-zero value (including undefined) it will attempt to restore the previous color selection if available.
9f4f238
to
955250b
Compare
Depends on: #31483Related issues: #31333, #31337
Related PRs: #31585
Description
As part of refining the border support provided UI, the border style dropdown is being replaced with a segmented control that does not include a
none
option. The idea is that setting a border width of0
should apply theborder-style: none
property.This PR updates the border width block support to update the border style attribute to
none
when the width is0
. It then also re-applies the previous style selection if possible when the width is changed to a non-zero number, including being reset to undefined.How has this been tested?
Test Setup
Turn on custom borders within your theme.json file.
Test Instructions
0
. The border style buttons should all be deselected.0
again, switch to the code editor view and confirm that the border style attribute is now set tonone
and the appropriate style is applied within the markup.Screenshots
ZeroBorderWidthSetsStyleNone.mp4
Types of changes
New feature
Checklist:
*.native.js
files for terms that need renaming or removal).