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

Border Radius serialized with unit set to undefined #35628

Closed
ockham opened this issue Oct 14, 2021 · 6 comments · Fixed by #35651
Closed

Border Radius serialized with unit set to undefined #35628

ockham opened this issue Oct 14, 2021 · 6 comments · Fixed by #35651
Assignees
Labels
[Block] Buttons Affects the Buttons Block [Block] Group Affects the Group Block (and row, stack and grid variants) [Block] Image Affects the Image Block [Block] Pullquote Affects the Pullquote Block [Block] Search Affects the Search Block - used to display a search field [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Feature] Inspector Controls The interface showing block settings and the controls available for each block Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@ockham
Copy link
Contributor

ockham commented Oct 14, 2021

Description

When setting the border radius via the slider control for any block that supports it, but not changing the default unit (px), the latter is serialized in the corresponding block attribute as undefined.

Potentially relevant PRs: #33017 #33117 cc/ @aaronrobertshaw @ntsekouras @oandregal

Also cc/ing @andrewserong @ciampo (b/c #35281) -- Is there anything we can do to catch an issue like this at compile time level (e.g. by typing potential values of the unit in UnitControl?)

Step-by-step reproduction instructions

  1. Insert a block that has support for setting the border radius (Button, Group, Image, Pullquote, Search).
  2. Use the sidebar control for setting the border radius, and set to an arbitrary value. Don't change the unit but leave it at its default px.
  3. Switch to the code editor to inspect.

Screenshots, screen recording, code snippet

border-radius

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@ockham ockham added [Type] Bug An existing feature does not function as intended [Feature] Inspector Controls The interface showing block settings and the controls available for each block [Block] Image Affects the Image Block [Block] Buttons Affects the Buttons Block [Block] Pullquote Affects the Pullquote Block [Block] Group Affects the Group Block (and row, stack and grid variants) [Block] Search Affects the Search Block - used to display a search field Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Oct 14, 2021
@oandregal oandregal added the [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi label Oct 14, 2021
@andrewserong
Copy link
Contributor

andrewserong commented Oct 14, 2021

Interesting issue, thanks for the ping @ockham! I can only recreate this if I click a single time on the RangeControl for the border radius, without sliding left or right at all. If I enter a value directly in the UnitControl, or if I slide to adjust the range control at all, then the px unit is used and updated correctly in the code editor view.

I'll do a bit more digging, but I suspect there'll be some logic we might need to update in https://github.com/wordpress/gutenberg/blob/trunk/packages/block-editor/src/components/border-radius-control

EDIT: I think this line is the culprit.

@andrewserong
Copy link
Contributor

I've opened a fix in #35651

@ciampo
Copy link
Contributor

ciampo commented Oct 15, 2021

typing potential values of the unit in UnitControl

Hey @ockham, if I understand correctly what you meant, @andrewserong and I discussed it in #35138 (comment) and decided to leave it as a loose string type

@ockham
Copy link
Contributor Author

ockham commented Oct 15, 2021

typing potential values of the unit in UnitControl

Hey @ockham, if I understand correctly what you meant, @andrewserong and I discussed it in #35138 (comment) and decided to leave it as a loose string type

Thanks @ciampo! Yeah, that's what I meant 😄 That comment makes sense. However, I wonder how an undefined value could slip through if the type is set to string? 🤔 Maybe it's accidentally converted to an 'undefined' string somewhere? 🤔

@ciampo
Copy link
Contributor

ciampo commented Oct 15, 2021

Judging by the fix in #35651, could it be that the file where the bug originated from was not type-checked?

@ockham
Copy link
Contributor Author

ockham commented Oct 15, 2021

Judging by the fix in #35651, could it be that the file where the bug originated from was not type-checked?

Ah, quite possibly! 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Buttons Affects the Buttons Block [Block] Group Affects the Group Block (and row, stack and grid variants) [Block] Image Affects the Image Block [Block] Pullquote Affects the Pullquote Block [Block] Search Affects the Search Block - used to display a search field [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Feature] Inspector Controls The interface showing block settings and the controls available for each block Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants