Subject of the issue
Follow-up to #844. The fix added window.getSelection()?.removeAllRanges() to _refocusCurrentActiveElement() to clear Firefox's persistent selection anchor after programmatic focus. However, _refocusCurrentActiveElement() is also called from _onClick() (js/a11y/browserFocus.js:125) on every click that doesn't land on a focusable element. The click event fires on mouseup, by which time the user's drag-selection has been committed - so the new call unconditionally wipes any text the user just selected.
Net effect: text selection is now broken in all browsers (not just Firefox) when _accessibility._isEnabled is true.
Your environment
Steps to reproduce
- In
config.json, set _accessibility._isEnabled: true
- Open any page with body text
- Click-and-drag to select text
Expected behaviour
Selected text remains selected after mouseup.
Actual behaviour
Selection is cleared the moment mouseup fires, because the click handler invokes _refocusCurrentActiveElement() -> removeAllRanges().
Proposed fix
Only clear the selection when it's collapsed (i.e. a stray programmatic anchor with no actual range). Genuine user selections from a drag are non-collapsed and should be preserved.
_refocusCurrentActiveElement() {
const element = this.a11y.currentActiveElement;
if (!element) return;
this.a11y.focus(element, { preventScroll: true });
const selection = window.getSelection();
if (selection?.isCollapsed) selection.removeAllRanges();
}
Drag-select -> non-collapsed range -> preserved.
Firefox programmatic anchor -> collapsed -> cleared (original #844 intent retained).
Posted via collaboration with Claude Code
Subject of the issue
Follow-up to #844. The fix added
window.getSelection()?.removeAllRanges()to_refocusCurrentActiveElement()to clear Firefox's persistent selection anchor after programmatic focus. However,_refocusCurrentActiveElement()is also called from_onClick()(js/a11y/browserFocus.js:125) on every click that doesn't land on a focusable element. Theclickevent fires onmouseup, by which time the user's drag-selection has been committed - so the new call unconditionally wipes any text the user just selected.Net effect: text selection is now broken in all browsers (not just Firefox) when
_accessibility._isEnabledis true.Your environment
Steps to reproduce
config.json, set_accessibility._isEnabled: trueExpected behaviour
Selected text remains selected after
mouseup.Actual behaviour
Selection is cleared the moment
mouseupfires, because the click handler invokes_refocusCurrentActiveElement()->removeAllRanges().Proposed fix
Only clear the selection when it's collapsed (i.e. a stray programmatic anchor with no actual range). Genuine user selections from a drag are non-collapsed and should be preserved.
Drag-select -> non-collapsed range -> preserved.
Firefox programmatic anchor -> collapsed -> cleared (original #844 intent retained).
Posted via collaboration with Claude Code