docs/solutions/logic-errors/2026-04-15-projected-segment-focus-should-not-clobber-dom-caret.md
markdown-preview rendered bold markdown through projection slices. Clicking
inside the projected bold span visually placed the browser caret in the bold
text, but Slate focus restoration snapped the DOM selection back to the default
Slate selection.
Backspace then ran against the wrong Slate selection and became a no-op.
Editable focus restoration now checks whether the browser already has a real
DOM selection inside the editor before restoring the initial/default Slate
selection on the delayed focus pass.
The key rule:
Editable key handling also syncs from the current DOM selection before
handling plain Enter, Backspace, and Delete, so keyboard actions use the
actual browser caret when projected text wrappers are involved.
Projected segments introduce extra DOM wrappers around a single Slate text node. The DOM bridge can map those points correctly, but only if the focus handler does not overwrite the browser selection first.
The fix keeps the browser's real caret as the source of truth when it is already inside the editor.
For Slate v2 projected text:
Regression owner: