Open Bug 1455286 Opened 7 years ago Updated 2 years ago

[contenteditable] Inconsistent behavior when inserting a space

Categories

(Core :: DOM: Editor, defect, P3)

59 Branch
defect

Tracking

()

People

(Reporter: wowmotty, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Whiteboard: [h2review-noted])

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0 Build ID: 20180323154952 Steps to reproduce: I set up this demo to show the problem - https://jsfiddle.net/Mottie/okza6kpL/. The demo uses `document.execCommand('insertText', false, ' ')` to insert a plain space at the end of a contenteditable div. In the demo, click the "Insert Space" button and view the results in the textarea. Actual results: Firefox initially inserts a regular space followed by a break `<br>`. On repeated clicking of the insert space button, non-breaking spaces are inserted before the `<br>`. Expected results: Chrome, Edge and Opera (I don't own a Mac to test it in Safari) only insert a non-breaking space. On repeated clicking of the insert space button, both non-breaking spaces and regular spaces are inserted.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3

Hi Rob, can you describe how you ran into this difference in behavior? Was it on a website, or something you were working on? Thanks.

Flags: needinfo?(wowmotty)
Whiteboard: [h2review-noted]

I discovered it while working on my virtual keyboard library: https://github.com/Mottie/Keyboard

Flags: needinfo?(wowmotty)

(In reply to Rob G from comment #2)

I discovered it while working on my virtual keyboard library: https://github.com/Mottie/Keyboard

Thanks Rob -- that's useful to know.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.