- Notifications
You must be signed in to change notification settings - Fork1.1k
Commit7596228
committed
Safari: fix incorrect cursor position after smart quote insertion
Safari 26 positions the cursor incorrectly after smart quotes textsubstitution, causing it to jump back 1-2 characters.After insertReplacementText events, the cursor is incorrectlypositioned. Trix's selectionDidChange handler syncs, corrupting itsinternal state.Hack to work around it:* Detect whether replacement is "at cursor" (smart quotes) vs "before cursor" (autocorrect) with <= 2 char distance heuristic.* For at-cursor replacements: manually calculate correct positioning accounting for length diff and triggering character (+1); set cursor in Trix; skip 3 input events to prevent corrupt sync; prevent selectionDidChange from syncing in the meantime; restore cursor position in requestAnimationFrame (no visible cursor movement).To reproduce the issue: enable Edit > Substitutions > Smart Quotes inSafari, hit Enter twice then "I'll " - including the final space. Thecursor should remain after the final space, no after the replacedapostrophe. Similarly with autocorrect: the cursor should not move tothe end of the spelling-corrected word.1 parentb307451 commit7596228
File tree
4 files changed
+2149
-1963
lines changed- action_text-trix/app/assets/javascripts
- src
- test/system
- trix
- controllers
- models
4 files changed
+2149
-1963
lines changed0 commit comments
Comments
(0)