Case ce-0138-selection-collapse-on-click · Scenario scenario-selection-restoration

Selection collapses unexpectedly when clicking during editing

OS: macOS 14.0 Device: Desktop or Laptop Any Browser: Safari 17.0 Keyboard: US Status: draft
selection click collapse safari

Phenomenon

When clicking on the contenteditable element during editing operations in Safari, the text selection may collapse unexpectedly. The selection range becomes invalid or moves to an unexpected position.

Reproduction example

  1. Select some text
  2. Click elsewhere in the contenteditable
  3. Observe selection state

Observed behavior

  • Selection collapses to a point
  • Or selection moves to unexpected position
  • Selection range may become invalid
  • Cannot maintain selection across clicks

Expected behavior

  • Selection should collapse to click position (normal behavior)
  • Or selection should be maintained if desired
  • Behavior should be predictable
  • Selection should remain valid

Browser Comparison

  • Chrome/Edge: Selection generally behaves correctly
  • Firefox: Selection may collapse unexpectedly
  • Safari: Selection collapse most unpredictable (this case)

Notes and possible direction for workarounds

  • Handle click events to preserve selection if needed
  • Restore selection after click if desired
  • Document selection collapse behavior
  • Consider if selection should persist across clicks
Before
Hello World Test
Selected text (World)
After Click (Bug)
Hello World Test
Click collapses or invalidates selection at unexpected position
vs
✅ Expected
Hello World Test
Expected: Selection collapses to click position (predictable behavior)

Browser compatibility matrix

This matrix shows which browser and OS combinations have documented cases for this scenario. The current case is highlighted. Click on a cell to view other cases.

Current case
Confirmed
Draft
No case documented

All variants (detailed table)

Complete list of all cases for this scenario with full environment details.

Case OS Device Browser Keyboard Status
ce-0110-selection-lost-after-dom-update Windows 11 Desktop or Laptop Any Chrome 120.0 US draft
ce-0130-selection-invalid-after-wrap Windows 11 Desktop or Laptop Any Firefox 120.0 US draft
ce-0138-selection-collapse-on-click macOS 14.0 Desktop or Laptop Any Safari 17.0 US draft
ce-0149-selection-range-invalid-after-insert Windows 11 Desktop or Laptop Any Firefox 120.0 US draft
ce-0172-selection-invalid-after-replace Windows 11 Desktop or Laptop Any Safari 17.0 US draft

Playground for this case

Use the reported environment as a reference and record what happens in your environment while interacting with the editable area.

Reported environment
OS: macOS 14.0
Device: Desktop or Laptop Any
Browser: Safari 17.0
Keyboard: US
Your environment
Sample HTML:
Event log
Use this log together with the case description when filing or updating an issue.
0 events
Interact with the editable area to see events here.

Comments & Discussion

Have questions, suggestions, or want to share your experience? Join the discussion below.