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

fix: [M3-7565] - Fix Radio size prop not affecting the radio button's dimensions #11242

Merged
merged 10 commits into from
Dec 4, 2024

Conversation

zaenab-akamai
Copy link
Contributor

@zaenab-akamai zaenab-akamai commented Nov 12, 2024

Description 📝

We realized this issue while working on the Radio storybook: changing the size prop of the radio did not actually affect the radio's appearance.

I noticed the size of the radio buttons was always 25px - which was coming from the width and height set in radio.svg and radioRadioed.svg. The font-size being set had no effect on the radio's dimensions.

Changes 🔄

  • Passed height and width to RadioIconRadioed and RadioIcon based on the size prop's value
  • Updated expected sizes in pixels per @gitkcosby's suggestion - 16px for small and 20px for medium.

Target release date 🗓️

NA

Preview 📷

How to test 🧪

Reproduction steps

  • Set the size prop to "small" and then "medium" of any radio button. Inspect on the browser - you should see 25px for both cases

Verification steps

  • Pull the PR, Set the size prop to "small" and then "medium" of any radio button. Inspect on the browser. Small radios should have a width of 16px and medium 20px.
    NOTE: It's possible that updating the medium radio size to 20px could cause alignment issues on pages where radios are used. We'll need to test this

As an Author I have considered 🤔

Check all that apply

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@zaenab-akamai zaenab-akamai changed the title Theme layer MuiSvgIcon style override prevents size prop from working fix: [M3-7565] - Fix Radio size prop Nov 14, 2024
@zaenab-akamai zaenab-akamai changed the title fix: [M3-7565] - Fix Radio size prop fix: [M3-7565] - Fix Radio size prop not affecting the radio button's dimensions Nov 14, 2024
@zaenab-akamai zaenab-akamai marked this pull request as ready for review November 19, 2024 09:11
@zaenab-akamai zaenab-akamai requested a review from a team as a code owner November 19, 2024 09:11
@zaenab-akamai zaenab-akamai requested review from carrillo-erik and hkhalil-akamai and removed request for a team November 19, 2024 09:11
@hkhalil-akamai
Copy link
Contributor

The ticket mentions removing the hardcoded size from the theme file and fixing any regressions... are we still planning to do that? (cc @coliu-akamai)

@@ -22,11 +22,18 @@ import { RadioIcon, RadioIconRadioed } from '../../assets/icons';
- Give people control and align with their expectations
*/
export const Radio = (props: RadioProps) => {
const sizeInPixels: Record<string, string> = {
medium: '20px',
small: '16px',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a large to this for 24px

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jaalah-akamai, I tried doing this.
MUI defines size (under RadioProps) with: size?: OverridableStringUnion<'small' | 'medium', RadioPropsSizeOverrides>; so we have just small and medium right now.

I considered extending RadioProps and adding on "large" but then we're spreading props into _Radio (MUI's original Radio) so it fails there (because _Radio doesn't know about large).

Would you happen to know a way to make this work? I might be missing something

@jaalah-akamai
Copy link
Contributor

I agree with @hkhalil-akamai we need to remove this: https://github.com/linode/manager/blob/develop/packages/ui/src/foundations/themes/light.ts#L1152-L1158 ultimately, but that will require some additional QA work in places we use icons

data-qa-radio={props.checked || false}
icon={<RadioIcon />}
icon={<RadioIcon height={iconDimension} width={iconDimension} />}
Copy link
Contributor

@jaalah-akamai jaalah-akamai Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we wrap any custom icons in SvgIcon MUI wrapper so we can use the built-in size prop instead of controlling the height/width manually. See: https://mui.com/material-ui/icons/#size

Alternatively we could also use createSvgIcon

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Along those lines, I wonder if we coud/should implement this in the theme rather than in the component. packages/ui/src/foundations/themes/light.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done. I updated packages/ui/src/foundations/themes/light.ts to make the font sizes work. We could get these values from design tokens if they're present.

Copy link

github-actions bot commented Dec 2, 2024

Coverage Report:
Base Coverage: 86.95%
Current Coverage: 86.95%

@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🎉 462 passing tests on test run #9 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
0 Failing462 Passing2 Skipped100m 42s

@jaalah-akamai jaalah-akamai merged commit c537af2 into linode:develop Dec 4, 2024
23 checks passed
Copy link

cypress bot commented Dec 4, 2024

Cloud Manager E2E    Run #6916

Run Properties:  status check failed Failed #6916  •  git commit c537af2b61: fix: [M3-7565] - Fix Radio size prop not affecting the radio button's dimensions...
Project Cloud Manager E2E
Branch Review develop
Run status status check failed Failed #6916
Run duration 30m 25s
Commit git commit c537af2b61: fix: [M3-7565] - Fix Radio size prop not affecting the radio button's dimensions...
Committer zaenab-akamai
View all properties for this run ↗︎

Test results
Tests that failed  Failures 1
Tests that were flaky  Flaky 3
Tests that did not run due to a developer annotating a test with .skip  Pending 2
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 464
View all changes introduced in this branch ↗︎

Tests for review

Failed  cypress/e2e/core/linodes/linode-config.spec.ts • 1 failed test

View Output Video

Test Artifacts
Linode Config management > End-to-End > Clones a config Screenshots Video
Flakiness  linode-config.spec.ts • 1 flaky test

View Output Video

Test Artifacts
Linode Config management > End-to-End > Boots a config Screenshots Video
Flakiness  clone-linode.spec.ts • 1 flaky test

View Output Video

Test Artifacts
clone linode > can clone a Linode from Linode details page Screenshots Video
Flakiness  update-linode-labels.spec.ts • 1 flaky test

View Output Video

Test Artifacts
update linode label > updates a linode label from details page Screenshots Video

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants