gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

When border width is set first, the default black color is not reflected by the border color control.

Open dpmehta opened this issue 9 months ago • 1 comments

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 ?

  1. Desynchronization of states

    • UI does not represent real block style
  2. User Confusion

    • User thinks:

    "No Color is applied" while black is actually rendered

Step-by-step reproduction instructions

  1. Add a Paragraph block.

  2. Set a border width without selecting a border color.

  3. 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

dpmehta avatar Feb 12 '26 11:02 dpmehta

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?

harshbhonsle avatar Feb 13 '26 07:02 harshbhonsle