When border width is set first, the default black color is not reflected by the border color control.
Description
When setting a border width on block before choosing a border color, Gutenberg automatically applies a default black color which is expected fallback behaviour However the border color control in the sidebar still shows that no color is selected.
This causes a mismatch between the UI control state and the rendered border color.
Why this matters ?
-
Desynchronization of states
- UI does not represent real block style
-
User Confusion
- User thinks:
"No Color is applied" while black is actually rendered
Step-by-step reproduction instructions
-
Add a Paragraph block.
-
Set a border width without selecting a border color.
-
Observe:
-
A black border is rendered.
-
The border color control still indicates no color selected.
-
Screenshots, screen recording, code snippet
https://github.com/user-attachments/assets/712c79c9-d4d3-4fce-8324-cba3333f899e
Environment info
No response
Please confirm that you have searched existing issues in the repo.
- [x] Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- [x] Yes
Please confirm which theme type you used for testing.
- [x] Block
- [ ] Classic
- [ ] Hybrid (e.g. classic with theme.json)
- [ ] Not sure
I’ve checked the serialization logic in border.js (styleToAttributes, attributesToStyle) and the BorderPanel inspector. The issue occurs because when a border width is set without a color, the browser renders black by default but the control still shows “no color.”
My approach will be to update the BorderPanel logic so that if width exists but color is unset, it reflects the fallback (black or the theme.json-defined default). This should sync the UI with the rendered style. Can I be assigned to this issue and raise a PR? Also, is this approach the right direction?