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

Bug: aspectRatio not being applied via style #21098

Closed
mattgperry opened this issue Mar 25, 2021 · 7 comments · Fixed by #21100
Closed

Bug: aspectRatio not being applied via style #21098

mattgperry opened this issue Mar 25, 2021 · 7 comments · Fixed by #21100
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@mattgperry
Copy link

React version: 16.14.0, 17.0.2

Steps To Reproduce

  1. Apply aspectRatio via style - no aspectRatio applied
  2. Add via className - aspectRatio applied

Needs Chrome 79 or above:
Link to code example: https://codesandbox.io/s/react-bug-not-applying-aspect-ratio-via-style-w2pqh?file=/src/App.js

The current behavior

No aspectRatio rule applied:
https://codesandbox.io/s/react-bug-not-applying-aspect-ratio-via-style-w2pqh?file=/src/App.js

The expected behavior

aspectRatio applied, here I'm adding it via a useLayoutEffect:
https://codesandbox.io/s/currying-hill-i09qn?file=/src/App.js

@mattgperry mattgperry added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Mar 25, 2021
@adyz
Copy link

adyz commented Mar 25, 2021

Yes, I have the same issue with another style property
Basically I want to add font-feature-settings: "tnum" or fontFeatureSettings and it gets removed.

https://codesandbox.io/s/custom-css-why-no-work-66ve2

@sebmarkbage
Copy link
Collaborator

sebmarkbage commented Mar 25, 2021

Try passing a string instead of number. React special cases numbers (to add the "px" suffix) and only doesn't for certain known attributes. So new ones sometimes need to be added to this list if they shouldn't get a px suffix (most should): https://github.com/facebook/react/blob/master/packages/react-dom/src/shared/CSSProperty.js#L11

@sebmarkbage
Copy link
Collaborator

sebmarkbage commented Mar 25, 2021

@adyz Your issue is unrelated. Would you mind opening a separate issue for that thread?

Basically try fontFeatureSettings: '"tnum"' instead. I.e. double strings. It's confusing but CSS expects a JS string of a CSS string. This is similar to how you have to do background: 'url("...")' in React but it's a little clearer there because it's a url(...) wrapper around it.

@mattgperry
Copy link
Author

Thanks @sebmarkbage

@gaearon
Copy link
Collaborator

gaearon commented Mar 25, 2021

#21100

@gaearon
Copy link
Collaborator

gaearon commented Mar 26, 2021

@mattgperry how soon do you need this? Are you blocked?

@mattgperry
Copy link
Author

mattgperry commented Mar 26, 2021

@gaearon no, no rush at all! Just something I stumbled upon. Thanks for the lightning-quick response though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants