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

<textarea> and <pre> content is not converted properly #22

Closed
sicks opened this issue Sep 4, 2015 · 12 comments
Closed

<textarea> and <pre> content is not converted properly #22

sicks opened this issue Sep 4, 2015 · 12 comments

Comments

@sicks
Copy link

sicks commented Sep 4, 2015

The following rules are affecting <textarea> and <pre> when the page renders:

All lines having leading or trailing whitespace are trimmed, all newlines are
removed, adjacent text separated by newlines become separated by a single
space. Any whitespace tabs are replaced with spaces. Strings inside
expressions are unaffected.

Summarized from this pull request. I was originally looking for a way to opt-out a specific element from this, but after reading how react normally works with JSX components I'm not sure how to address this if you're building your UI with something else.

@sicks
Copy link
Author

sicks commented Sep 4, 2015

It looks like this is actually due to the HTMLtoJSX converter. I don't think it produces the JSX necessary to maintain textarea and pre tag contents, here's a fiddle demonstrating this.

@sicks sicks changed the title JSX whitespace coalescing rules break <textarea> and <pre> content <textarea> and <pre> content is not converted properly Sep 4, 2015
@sicks
Copy link
Author

sicks commented Sep 4, 2015

Moved this to react-magic#33 as that's where the HTMLtoJSX converter lives.

@sicks sicks closed this as completed Sep 4, 2015
@sicks
Copy link
Author

sicks commented Sep 13, 2015

fixed in reactjs/react-magic@8b90aa3

@ssorallen
Copy link
Owner

Perfect, thanks for the note. I will update turbo-react with the latest react-magic.

@sicks
Copy link
Author

sicks commented Sep 14, 2015

Thanks! Don't forget the rails gem!

ssorallen added a commit that referenced this issue Sep 15, 2015
* Fixes #22: `<textarea>` and `<pre>` content not being converted
  properly
@ssorallen
Copy link
Owner

Pushed an updated version of the JS and of the Ruby gem with the update assets.

@tom-orrow
Copy link

Hi. A bit of explanation could be nice. How can I render textarea with new lines? Value attribute still replaces line breaks with spaces. Default value attribute seems not working.

@sicks
Copy link
Author

sicks commented Sep 28, 2015

@tom-orrow this was fixed in reactjs/react-magic@8b90aa3, but broken again when turbo-react's version of turbolinks was updated to non-stable version, see #24.

@sicks
Copy link
Author

sicks commented Sep 28, 2015

Actually I just realized I hadn't switched back to the original turbo_react-rails gem. @ssorallen your release doesn't appear to include the newline fixes, any idea?

@ssorallen
Copy link
Owner

@sickslives turbo-react does not bundle Turbolinks any more, so turbo-react needs to the react-magic fix in order to work with Edge Turbolinks.

Is there a release of react-magic with the fix? I can update both turbo-react and turbo-react_rails with it.

@sicks
Copy link
Author

sicks commented Sep 29, 2015

@ssorallen The current master branch of react-magic includes the textarea/pre fix, I'm not sure why it didn't come through in your bundle. I got it working in my fork but since the file's minified I can't really tell why mine works and yours doesn't.

Covering all the bases, did you remember to copy the dist version over to turbo_react-rails's vendor folder after building turbo-react? :P

@ssorallen
Copy link
Owner

The commit to fix <textarea> and <pre> is not yet in a release for html-to-jsx. The latest is v0.2.4, but the commit is only in master: reactjs/react-magic@release-0.2.4...master

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

3 participants