Select All (Ctrl+A) fails when non-editable block is first or last child
OS: macOS 14 · Device: Desktop Any · Browser: Safari 17 · Keyboard: US QWERTY
Open case →Scenario
When a contenteditable element has a non-editable block as its first or last child, Ctrl+A (Select All) collapses the selection in the wrong direction instead of selecting all content, breaking WYSIWYG expectations.
In contenteditable regions that contain non-editable block elements (e.g. embedded widgets, images, or blocks with contenteditable="false"), pressing Ctrl+A (or Cmd+A) is expected to select all content. In Safari, Chrome, and Opera, when the non-editable block is the first or last child of the contenteditable root, the selection collapses in the opposite direction from that block instead of selecting the entire content. This makes “Select All” unreliable in WYSIWYG editors that mix editable text with non-editable blocks.
contenteditable="false" (or equivalent) at the start or end.Example structure:
<div contenteditable="true">
<div contenteditable="false">[Embedded widget]</div>
<p>Editable paragraph one.</p>
<p>Editable paragraph two.</p>
</div>
With cursor in the second paragraph, Ctrl+A may select only the two paragraphs and leave the first child (the widget) out, or collapse to a single point instead of a full range.
keydown (Ctrl+A), prevent default, and programmatically select the entire contenteditable root (e.g. range.selectNodeContents(editor)), then selection.removeAllRanges(); selection.addRange(range).Example programmatic select-all:
editor.addEventListener('keydown', (e) => {
if ((e.ctrlKey || e.metaKey) && e.key === 'a') {
e.preventDefault();
const sel = window.getSelection();
const range = document.createRange();
range.selectNodeContents(editor);
sel.removeAllRanges();
sel.addRange(range);
}
});
Visual view of how this scenario connects to its concrete cases and environments. Nodes can be dragged and clicked.
Each row is a concrete case for this scenario, with a dedicated document and playground.
| Case | OS | Device | Browser | Keyboard | Status |
|---|---|---|---|---|---|
| ce-0583 | macOS 14 | Desktop Any | Safari 17 | US QWERTY | draft |
Open a case to see the detailed description and its dedicated playground.
OS: macOS 14 · Device: Desktop Any · Browser: Safari 17 · Keyboard: US QWERTY
Open case →Other scenarios that share similar tags or category.
When the browser is zoomed (or content is scaled via CSS transforms), caret position and text selection in contenteditable elements can become inaccurate. Clicking at a certain position places the caret elsewhere, and selection highlights may not match the visual selection.
When deleting the last character before a non-editable "pill" or tag element (contenteditable="false") in a contenteditable div in Chrome, the caret (cursor) jumps to the end of the entire contenteditable div instead of staying adjacent to the remaining content.
When contenteditable='false' elements are placed inside a contenteditable container, the cursor may disappear or become invisible in certain browsers, making it difficult for users to determine the text insertion point.
After copying selected text in a contenteditable region using Cmd+C, the selection is lost in Safari. The user must re-select the text to perform additional operations.
When a contenteditable element or its parent has the CSS contain property, selection behavior may be affected. Selection may not extend beyond the contained element, and caret movement may be restricted.
Have questions, suggestions, or want to share your experience? Join the discussion below.