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

Nested hyperlinks with neighbouring image are styled wrong #344

Closed
sebk opened this issue Feb 24, 2020 · 4 comments · Fixed by #434
Closed

Nested hyperlinks with neighbouring image are styled wrong #344

sebk opened this issue Feb 24, 2020 · 4 comments · Fixed by #434
Labels
bug Crush'em all. domain:layout Positional issues, such as inline images.

Comments

@sebk
Copy link

sebk commented Feb 24, 2020

Is this a bug report or a feature request?

Bug report

Have you read the guidelines regarding bug report?

Yes

Have you read the documentation in its entirety?

Yes

Have you made sure that your issue hasn't already been reported/solved?

Yes

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

Both platforms

Is the bug reproductible in a production environment (not a debug one)?

Yes

Have you been able to reproduce the bug in the provided example?

Yes

Environment

Environment:
React: 16.9.0
React native: 0.61.4
react-native-render-html: 4.2.0

Target Platform:
Android (8.0)
iOS (13.3)

Steps to Reproduce

  1. Run the example. Both links are inside a <p>-Tag. One of the has an image as a neighbour.

Expected Behavior

Both links are inside a <p>-Tag. One of the has an image as a neighbour. The expected behaviour is that all text not in a link is renderer red and both links are rendered green.

Actual Behavior

The link that has an image as a neighbour is renderer in the color of the parent paragraph (red). The link without an image as a neighbour is rendered green.

Reproducible Demo

https://snack.expo.io/B1PshHbVL

Check on iOS for example (not web).

@jsamr jsamr added bug Crush'em all. domain:layout Positional issues, such as inline images. labels Jul 4, 2020
@jsamr
Copy link
Collaborator

jsamr commented Jul 19, 2020

@sebk I implemented a test that could reproduce the issue. Will investigate on the cause and provide a fix before 4.2.2 release.

@jsamr
Copy link
Collaborator

jsamr commented Jul 20, 2020

@sebk Unfortunately a fix is non-trivial. The incriminated code is situated here: src/HTML.js#L370. Basically, what happens is that text styles which should be inherited to children are force-written into children's htmlAttribs.styles, aka inline styles. Because inline styles take precedence over tagsStyles, the later are ignored. We should instead store the information about inherited styles in a separate structure that has less precedence than tagsStyles. The restructuration will not happen before 6.X, but at least I have the test merged to master, see 7c8d26a.

We might consider to make the inheritance behavior opt-in for the 5.0 release, with a prop such as enableExperimentalCSSInlineTextStyleInheritance which would address your issue in the meantime.

@gazedash
Copy link

gazedash commented Oct 5, 2020

@jsamr what can I do now to change the color of a link?

@jsamr jsamr linked a pull request Nov 26, 2020 that will close this issue
41 tasks
@jsamr jsamr mentioned this issue Nov 26, 2020
41 tasks
@jsamr
Copy link
Collaborator

jsamr commented Nov 26, 2020

This issue has been fixed in the Foundry release. Try it out now! See #430 for instructions.

@jsamr jsamr closed this as completed in #434 Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Crush'em all. domain:layout Positional issues, such as inline images.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants