Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

wysihtml5-0.4.0pre.js + textarea hidden + Firefox = TypeError: sel.nativeSelection is null #371

Open
jeromelefeuvre opened this issue Apr 11, 2013 · 9 comments

Comments

@jeromelefeuvre
Copy link

Hi,

I know wysihtml5-0.4.0pre.js is not a final version but for your information when using it with a hidden textarea (in a tab for example) on Firefox, you have a js error:

TypeError: sel.nativeSelection is null
file:///..../wysihtml5-0.4.0pre.js
Line 2975

See example here: http://jsfiddle.net/EhbuY/

Thanks

@winds1983
Copy link

I also get this error in 0.3.0

@mattgoldman
Copy link

Experiencing same issue on v0.4.0.pre

@eric-wood
Copy link

Same issue here :(

Any ideas on how to resolve it?

@mattgoldman
Copy link

For me, not hiding the textarea on page load fixed it. Just remove display:none; if it's there.

---

Sent from my iPhone

On Fri, Sep 6, 2013 at 4:48 PM, Eric notifications@github.com wrote:

Same issue here :(

Any ideas on how to resolve it?

Reply to this email directly or view it on GitHub:
#371 (comment)

@eric-wood
Copy link

Thanks, that makes a bit more sense. I'll probably have to do a workaround like setting the opacity to hide the editor instead until there's a more permanent solution.

@glebm
Copy link

glebm commented Sep 10, 2013

@eric-wood
Copy link

I cannot thank you enough...that did the trick!

High-five! ✋

@nienn
Copy link

nienn commented Dec 6, 2013

I'm having the same issue. Using wysihtml5-0.4.0pre.js + Bootstrap tabs (which are hidding the textarea onload by applying a css class with display:none). Plus, I've set the option useLineBreaks: false.

On Firefox I get the console error sel.nativeSelection is null and both the original textarea and the wysihtml5 iframe are shown, but no toolbar is displayed.

When I apply @glebm's fix it works almost fine (Cheers for that one! Saved me from a really embarrassing script I was about to write). Only now, in Firefox, the editors inside tabs stoped making paragraphs and return only br's. This happens only in Firefox and only for editors that were hidden onload...

Anyone else having the same problem?

Edit: I'm also using bootstrap-wysihtml5 and I'm calling wysihtml5 after the tabs script. It's not very practical for me to change this order. Although I think that could fix it, I'd love to find a more permanent solution.

Maluen added a commit to Maluen/wysihtml5 that referenced this issue Feb 3, 2014
elmo61 added a commit to elmo61/wysihtml5 that referenced this issue Apr 2, 2015
This solution was provided by this issue tiff#371 but not implemented in this code, (it was implemented in the bootstrap version only

https://github.com/glebm/bootstrap-wysihtml5-rails/blob/master/vendor/assets/javascripts/bootstrap-wysihtml5/rangy/rangy-core.js#L2958
@stuxt
Copy link

stuxt commented Aug 16, 2016

I also get this error in 0.3.0

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

No branches or pull requests

7 participants