fix: RTL cursor jumping, character loss, and stale alignment#2119
Merged
Conversation
…S from text content Three changes to fix RTL cursor jumping, character loss, and stale alignment: 1. In setText, save text to store before calling setRtl. Previously setRtl ran first, triggering intermediate re-renders with stale text that caused cursor jumps and character loss (JS-8716, JS-9183). 2. Derive the isRtl CSS class from actual text content instead of the stored isRtlDetected flag. The flag lags behind text changes, keeping direction:rtl on the element after the user switches to LTR text (JS-9183, JS-6395). 3. Remove the `value &&` guard so clearing all text properly resets the RTL state. Previously, emptying an RTL block kept isRtlDetected=true, so the next block or continued LTR typing started with wrong alignment (JS-6395). 4. Skip leading whitespace in checkRtl so " مرحبا" is correctly detected. Fixes: JS-6395, JS-8716, JS-9183 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
setRtl, so intermediate re-renders from the RTL flag/alignment gRPC calls have the correct text. PreviouslysetRtlran first, causing re-renders with stale text that led to cursor jumps and first-character deletion when switching between LTR↔RTL.isRtlCSS class from actual text content (U.String.checkRtl(text)) instead of the storedfields.isRtlDetectedflag. The flag lags behind text changes, keepingdirection: rtlon the element after the user has already switched to LTR text.value &&guard insetTextso that clearing all text properly resets the RTL state. Previously emptying an RTL block keptisRtlDetected=true, so continued LTR typing started with wrong alignment.checkRtlregex now skips leading whitespace so" مرحبا"is correctly detected as RTL.Fixes
Test plan
🤖 Generated with Claude Code