Phenomenon
When a range of text is selected inside a contenteditable element, clicking outside the element
collapses the selection to a caret position inside the editable region instead of clearing the
selection entirely.
Reproduction example
- Focus the editable area.
- Type a few words across multiple lines.
- Drag to select part of a line or multiple lines.
- Click outside the editable area, for example on the page background.
Observed behavior
- The selection collapses to a single caret position inside the editable element.
- The range is not cleared, which can cause confusion for users relying on visual feedback.
Expected behavior
- The selection is cleared entirely when the element loses focus, or at least behaves similarly to native text fields in the same browser and OS combination.
Notes
- This behavior can affect keyboard shortcuts (for example, copy or delete) if they are bound to the selection state.