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

Picker (or TextInput) fontFamily breaks another component fontFamily #881

Closed
steida opened this issue Mar 31, 2018 · 30 comments
Closed

Picker (or TextInput) fontFamily breaks another component fontFamily #881

steida opened this issue Mar 31, 2018 · 30 comments
Labels
needs: more information Issue is missing actionable information

Comments

@steida
Copy link

steida commented Mar 31, 2018

Bug

When I set Picker a fontFamily, completely another component will lost its fontFamily style.

I will try to make and demo, meanwhile, some users can have a similar problem so I created an issue.

Btw, the bug I reported is still there: I updated an issue.
#879

Also, this is very probably related: #860 (comment)

@steida steida changed the title Picker Picker fontFamily breaks another component fontFamily Mar 31, 2018
@steida
Copy link
Author

steida commented Mar 31, 2018

There must be some race condition because I have two almost exactly the same apps. Here it works http://github.com/este/este, but in another private repo, when I add font family, completely another component will lose it.

@steida
Copy link
Author

steida commented Mar 31, 2018

As I debug it, it seems fontFamily is somehow incorrectly cached when I slightly change a definition for a picker, it works.

@steida steida changed the title Picker fontFamily breaks another component fontFamily Picker (or TextInput) fontFamily breaks another component fontFamily Mar 31, 2018
@steida
Copy link
Author

steida commented Mar 31, 2018

Just investigated the same behavior exists for TextInput.

@steida
Copy link
Author

steida commented Mar 31, 2018

Trying to isolate in glitch, without a success so far :-/
Leaving it here for further experimentation.

https://glitch.com/edit/#!/common-billboard

@necolas
Copy link
Owner

necolas commented Mar 31, 2018

I can't tell what you're trying to do in that glitch

@steida
Copy link
Author

steida commented Mar 31, 2018

Demonstrate a bug of course. I am using fairly complex setup: http://github.com/este/este
Isolation isn't easy, give me a time, please.

@steida
Copy link
Author

steida commented Mar 31, 2018

Anytime I set fontFamily for more components, one of them will lose it. It's happening I don't know why. Trying to isolate as much app code as possible.

@necolas
Copy link
Owner

necolas commented Mar 31, 2018

Also, this is very probably related: #860 (comment)

Picker doesn't support font family. See https://necolas.github.io/react-native-web/storybook/

@necolas necolas added the needs: more information Issue is missing actionable information label Mar 31, 2018
@steida
Copy link
Author

steida commented Mar 31, 2018

I just tried to replace import { StyleSheet } from 'react-native'; in my theme file with stub

const StyleSheet = {
  create: styles => styles,
};

And bug disappeared. Maybe I am doing something wrong.

@steida
Copy link
Author

steida commented Mar 31, 2018

It seems to be related to StyleSheet, not picker. Now I am investigating the same issue with TextInput.

@steida
Copy link
Author

steida commented Mar 31, 2018

Btw, so Picker fontSize isn't possible to set for web? It makes sense if RN does not support it.

@steida
Copy link
Author

steida commented Mar 31, 2018

It's definitely related to import { StyleSheet } from 'react-native'; Inline styles works well. Still don't know how to isolate it :-/

@steida
Copy link
Author

steida commented Mar 31, 2018

@necolas OK, It's time to give up it. Whenever I set a font family to TextInput, Text will lose it. There is definitely a bug in RNW StyleSheet. This is workaround I am going to use because don't know RNW source enough to be able to fix it.

textInput: StyleSheet.create({
    input: {
      color: colors[textColor],
      fontFamily: fontFamily + ' ',
      marginBottom: rhythm(1),
    },
  }),

@necolas
Copy link
Owner

necolas commented Mar 31, 2018

And this is not something you can reproduce in a simple test case? I'm not asking you to fix it at this stage. Are you mixing RNW with CSS from somewhere else?

@steida
Copy link
Author

steida commented Mar 31, 2018

No, because there is probably some race condition. As I wrote, I have two almost the same apps, it works in first and doesn't in second.

@steida
Copy link
Author

steida commented Mar 31, 2018

@necolas If it was my fault, please tell me where I shall send some bitcoins.

@necolas
Copy link
Owner

necolas commented Mar 31, 2018

Let me know if editing that este code doesn't resolve the issue

@steida
Copy link
Author

steida commented Mar 31, 2018

@necolas What's wrong with that? It's normal style definition. color and fontFamily.

@steida
Copy link
Author

steida commented Mar 31, 2018

As for "This is not needed because it's handled within RNW when you use the System font-family"

How is it related? I suppose it's perfect valid case to set custom fontFamily even similar to System. Am I wrong?

@necolas
Copy link
Owner

necolas commented Mar 31, 2018

What's wrong with that? It's normal style definition

Sorry, I was confused by the way you've defined the styles in another object.

I suppose it's perfect valid case to set custom fontFamily even similar to System

Sure

@steida
Copy link
Author

steida commented Mar 31, 2018

As for "Are you mixing RNW with CSS from somewhere else?" I used Next.js example. Nothing more I am aware of.

@steida
Copy link
Author

steida commented Mar 31, 2018

I guess there is something wrong with a cache. Este example works well, but the same Este app with less / different order components breaks fontFamily. I had the same issue when I tried to put styles to anchor manually instead of using Text with role prop which should work even it's not needed.

@steida
Copy link
Author

steida commented Mar 31, 2018

@necolas Not sure how the last commit should fix it. I tried fontFamily Arial with the same result.

@necolas
Copy link
Owner

necolas commented Mar 31, 2018

Last commit is unrelated. Without a test case or running example I can't help

@steida
Copy link
Author

steida commented Mar 31, 2018

I hope it's broken only for fontFamily. I will keep you informed.

@steida
Copy link
Author

steida commented Apr 1, 2018

Hmm, I think I know where is the problem. When I add fontFamily to TextInput, Text font inherit became stronger than fontFamily. That's weird.

screen shot 2018-04-01 at 17 54 49

@necolas Any idea why it can happen?

I will repeat it to be clear: When I add the same fontFamily as Text has to TextInput, Text will render with incorrect CSS specificity.

@steida
Copy link
Author

steida commented Apr 1, 2018

Note font inherit is later then fontFamily (first and last row). I bet this is the reason.

screen shot 2018-04-01 at 18 21 18

@steida
Copy link
Author

steida commented Apr 1, 2018

When I remove fontFamily from TextInput, Text fontFamily is rendered with correct specificity / order.

screen shot 2018-04-01 at 18 23 44

@necolas necolas closed this as completed in 23fa663 Apr 2, 2018
@steida
Copy link
Author

steida commented Apr 21, 2018

Thank you a lot for your hard super awesome work. RNW is gold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: more information Issue is missing actionable information
Projects
None yet
Development

No branches or pull requests

2 participants