Skip to content

Commit

Permalink
fix(kit): SelectionChangeHandler does not work for Safari after pro…
Browse files Browse the repository at this point in the history
…grammatic update of textfield value (#1930)
  • Loading branch information
nsbarsukov authored Jan 13, 2025
1 parent 4285b8d commit 34c11d0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion projects/kit/src/lib/plugins/selection-change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ export function maskitoSelectionChangeHandler(
};

document.addEventListener('selectionchange', listener, {passive: true});
// Safari does not fire `selectionchange` on focus after programmatic update of textfield value
element.addEventListener('focus', listener, {passive: true});
element.addEventListener('mousedown', onPointerDown, {passive: true});
document.addEventListener('mouseup', onPointerUp, {passive: true});

return () => {
document.removeEventListener('selectionchange', listener);
document.removeEventListener('mousedown', onPointerDown);
element.removeEventListener('focus', listener);
element.removeEventListener('mousedown', onPointerDown);
document.removeEventListener('mouseup', onPointerUp);
};
};
Expand Down

0 comments on commit 34c11d0

Please sign in to comment.