Open Bug 1513303 Opened 5 years ago Updated 2 years ago

contenteditable element breaks :empty selector in presence of pseudo elements

Categories

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

63 Branch
defect

Tracking

()

Tracking Status
firefox75 --- affected
firefox76 --- affected

People

(Reporter: jquerycla, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:63.0) Gecko/20100101 Firefox/63.0

Steps to reproduce:

1. Prepare a contenteditable element that renders a placeholder using the ::before technique (https://codepen.io/anon/pen/dwoNwp); Observe placeholder.
2. Type into element.
3. Delete all content from element.


Actual results:

Observe that the :empty selector no longer matches, despite the element having arguably been emptied out.


Expected results:

Since the user deleted all of the contents, the :empty selector should have matched again, restoring the placeholder pseudo element.
Component: Untriaged → Editor
Product: Firefox → Core
I could reproduce this with latest Nightly on Mac and Window 10.
Status: UNCONFIRMED → NEW
Ever confirmed: true
It looks like we leave a <br> element under contenteditable element, so it doesn't match the :empty selector. And it could be recovered by pressing enter and then deleting all content again.
Priority: -- → P3

(In reply to Edgar Chen [:edgar] from comment #2)

It looks like we leave a <br> element under contenteditable element, so it
doesn't match the :empty selector. And it could be recovered by pressing
enter and then deleting all content again.

The same behavior in the editor creates problems for users of Google Sheets: opening the editor on a cell and clearing an existing value before typing a new one injects <br> between those steps, which is invisible during editing and seemingly impossible to remove afterwards.

Tester page: https://www.jeffersonscher.com/res/editor-newline.html

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

Attachment

General

Creator:
Created:
Updated:
Size: