Using <input> inside a contenteditable="false" is broken in Firefox
See original GitHub issueWe noticed a bug in Firefox, rendering a node as follows is broken:
<div contenteditable="false">
<input type="text" />
</div>
There are two things to note:
- Left/right arrow keys don’t move the caret
- Pressing a character key (or backspace) throws an error:
Permission denied to access property “nodeType”
I created a repository reproducing the error with Slate and a minimal setup: http://gabinaureche.com/slate-firefox-bug/
The error comes from isInEditor
which tries to read window.getSelection().anchorNode.nodeType
but anchorNode
is “Restricted”.
This bug is reproducible without Slate, here’s a pretty simple scenario: https://jsfiddle.net/hsqebsk2/1/
I filed an issue to Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1449936
Probably related to #843
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:24 (6 by maintainers)
Top Results From Across the Web
contenteditable = false in firefox browser - Stack Overflow
I've used this solution here to counter that problem. It detects backspaces and checks if the element right before the caret has contenteditable ......
Read more >685445 - Contenteditable=false elements ... - Bugzilla@Mozilla
This bug is about Backspace not working on contenteditable=false elements in contenteditable=true elements at all, ever. Delete doesn't work on contenteditable= ...
Read more >Delete doesn't work correctly on contenteditable=false spans ...
This bug was about Delete not working only right after loading the web page. If you move the caret just one position or...
Read more >Bogus <br> is inserted at the beginning of contenteditable ...
This happens because while image is selected there's a hidden container in which we store selection. We call it a "fake selection" and...
Read more >Broken selection system inside of a nested contenteditable ...
The root cause of this bug is that -moz-user-select: all on a parent element overrides it on all children, so once an editable...
Read more >Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just wanted to outline how critical this is, as I’m not certain that’s clear.
This bug means projects that support Firefox, which is most projects, can’t use inputs in Slate, as Slate controls the
contenteditable
attributes within itself and I think they’re always false for void nodes.Best repro of this bug is in Slate’s example site - try editing the YouTube video url in firefox: https://www.slatejs.org/#/embeds
I’m working on tracking down the commit where this broke - we ran into it by upgrading
slate
from ^0.30 to ^0.34 andslate-react
from0.10.11
to0.12.9
.I’ve rolled back the regression that made inputs inside voids unable to be focused in all browsers, so this issue can remain for the Firefox case.