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

MarkupText only renders first child when using fallback #20

Closed
nephix opened this issue May 13, 2018 · 11 comments
Closed

MarkupText only renders first child when using fallback #20

nephix opened this issue May 13, 2018 · 11 comments

Comments

@nephix
Copy link

nephix commented May 13, 2018

Steps:

  1. Go to https://codesandbox.io/s/1zzm1n6npq
  2. Open en.json and locate news.title property
  3. See the correct output in result window: <span>This <em>should work</em></span>
  4. Change news.title in index.js to news.whatever

Expected Result:

The default text
<span>This <b>This doesnt work</b></span>
is rendered in the result window

Actual Result:

<span>This </span>
is rendered in the result window

@nephix nephix changed the title MarkupText doesn't render HTML tags in default text MarkupText doesn't render HTML tags of default text May 13, 2018
@azizhk
Copy link

azizhk commented May 14, 2018

This is because the following code seems to pick only the first child.

let fallback = children && children[0];

@billneff79
Copy link
Contributor

That is likely the issue. I would be happy to review a PR that changes it to just fallback = children and added test cases for a fallback with markup in it.

@billneff79 billneff79 changed the title MarkupText doesn't render HTML tags of default text MarkupText only renders first child when using fallback May 15, 2018
@nephix
Copy link
Author

nephix commented May 17, 2018

I changed it to fallback = children and implemented a test case but the issue remained. Not sure what the actual issue is. Can someone else with more experience have a look at it?

@azizhk
Copy link

azizhk commented May 17, 2018

Sorry try changing

fallback: def.children && def.children[0]

Your working example: https://codesandbox.io/s/31rq37xnn5

@nephix
Copy link
Author

nephix commented May 17, 2018

Hey @azizhk, thank you. Although that fixes the problem, it lets a bunch of other test cases fail.

@nephix
Copy link
Author

nephix commented May 18, 2018

Is there a chance of this getting fixed and released any time soon? It's currently blocking us from rolling out our app in another location.

@pl12133
Copy link
Contributor

pl12133 commented May 18, 2018

@nephix Surely, I would be happy to review a PR with the fix recommended by @azizhk.

@nephix
Copy link
Author

nephix commented May 18, 2018

@pl12133 sure, but the fix brings a whole lot of other issues when you run the tests that I'm not able to fix.

@azizhk
Copy link

azizhk commented May 18, 2018

Created a PR #21

@billneff79
Copy link
Contributor

This is resolved in preact-i18n@1.2.1

@gavmck
Copy link

gavmck commented Feb 12, 2020

Same issue with the basic <Text> field caused by the same line of code by the looks of it

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

No branches or pull requests

5 participants