Skip to content

[Bug] Parsed "aspect-ratio: 4/3" is causing errors in the android simulator #177

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

Closed
MarchewkaMatthew opened this issue Jan 11, 2023 · 7 comments

Comments

@MarchewkaMatthew
Copy link

MarchewkaMatthew commented Jan 11, 2023

Hi,

I have an issue with parsing the aspect-ratio property.

Steps to reproduce

  1. Go to https://csstox.surge.sh/
  2. Paste this code: aspect-ratio: 4/3;
  3. Output is: "aspectRatio": "4/3" instead of the "aspectRatio": 4/3

I do understand the rule of this lib described in the README:
Converts all number-like values to numbers, and string-like to strings.
but "4/3" is not a valid CSS or React native styles value.

Worth to mention that the "1/1" value works on iOS but crashes the app on Android.

Am I doing something wrong, or it should be fixed in the lib? :)
If it should be fixed I can help with the contribution (if it's needed)

Thanks in advance,
@MarchewkaMatthew

@jacobp100
Copy link
Contributor

It looks like we forgot to handle this when we made the library, so it passed it in as a string. At that time, react-native only supported numbers, so that was a bug. However, since then, react native started supported string values.

I can't tell you why it's broken on Android for you

That said, we'd also accept a PR to convert the a / b form to a number - it'll be more reliable, and improve ahead-of-time compilation for style sheets

@MarchewkaMatthew
Copy link
Author

MarchewkaMatthew commented Jan 11, 2023

I will look into it later today, just wanted to clarify that the string aspectRatio value is not working for iOS as well, it's just not breaking the app completely (just not applying any styles).

I have checked the typings for the StyleSheet, and even if they support the string value in the logic, they have not added it to the types:
image

@jacobp100
Copy link
Contributor

Ah ok. Looking at it further, the string support was added in 0.71, which is a release candidate

@MarchewkaMatthew
Copy link
Author

Hi @jacobp100, when I started implementing the changes, I found your old branch (from 2019) with the fix for that issue. The Name of the branch is: aspect-ratio. I can see that the PR with the changes was closed due to the early stage of the CSS aspect-ratio proposal but now RN StyleSheet supports the CSS-style aspect-ratio value (same as web). Can you publish the PR again?

#123

@jacobp100
Copy link
Contributor

Sorry - yes - you're right. I need to do a publish

@jacobp100
Copy link
Contributor

Published 3.1.0

@MarchewkaMatthew
Copy link
Author

Hi @jacobp100, I can see that you have bumped the version to 3.1.0 but I'm not sure are aspectRatio changes included in it. I have checked out the newest master and I can't see the aspectRatio file there. :)

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

No branches or pull requests

2 participants