wysihtml5 icon indicating copy to clipboard operation
wysihtml5 copied to clipboard

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

Open jeromelefeuvre opened this issue 11 years ago • 9 comments

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

jeromelefeuvre avatar Apr 11 '13 09:04 jeromelefeuvre

I also get this error in 0.3.0

winds1983 avatar Jul 23 '13 06:07 winds1983

Experiencing same issue on v0.4.0.pre

mattgoldman avatar Sep 03 '13 18:09 mattgoldman

Same issue here :(

Any ideas on how to resolve it?

eric-wood avatar Sep 06 '13 23:09 eric-wood

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 [email protected] wrote:

Same issue here :(

Any ideas on how to resolve it?

Reply to this email directly or view it on GitHub: https://github.com/xing/wysihtml5/issues/371#issuecomment-23976415

mattgoldman avatar Sep 07 '13 00:09 mattgoldman

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.

eric-wood avatar Sep 07 '13 04:09 eric-wood

I patched 1 line in rangy and it seems to fix the issue: https://github.com/glebm/bootstrap-wysihtml5-rails/blob/master/vendor/assets/javascripts/bootstrap-wysihtml5/rangy/rangy-core.js#L2958

glebm avatar Sep 10 '13 23:09 glebm

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

High-five! :hand:

eric-wood avatar Sep 11 '13 21:09 eric-wood

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.

nienn avatar Dec 06 '13 13:12 nienn

I also get this error in 0.3.0

stuxt avatar Aug 16 '16 03:08 stuxt