fix(macos): TextInput Fabric commands - setGhostText, blur, and selection fixes#2912
Open
Saadnajmi wants to merge 4 commits intomicrosoft:mainfrom
Open
fix(macos): TextInput Fabric commands - setGhostText, blur, and selection fixes#2912Saadnajmi wants to merge 4 commits intomicrosoft:mainfrom
Saadnajmi wants to merge 4 commits intomicrosoft:mainfrom
Conversation
- Add setGhostText command to Fabric TextInput native handler (was declared in JS but missing from native dispatch) - Port ghost text implementation from Paper to Fabric with proper Fabric API adaptations (NSRange selection, direct _backedTextInputView access) - Fix setTextAndSelection using notifyDelegate:YES instead of NO, matching Paper behavior to prevent spurious delegate callbacks - Add ghost text cleanup in textInputDidChange delegate - Add RNTesterPlayground test case for verifying TextInput ref and commands (focus, blur, clear, setSelection, setGhostText) - Add debug logging in setLocalRef to diagnose ref null issue - Add test assertions for setSelection and setGhostText methods Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix blur on Fabric: use currentEditor to detect focused NSTextField (field editor mismatch made blur a silent no-op) - Prevent ghost text from being selectable on Fabric by clearing it in textInputDidChangeSelection, matching Paper behavior - Remove TARGET_OS_OSX guard from setGhostText command dispatch (was causing compilation issues with preprocessor) - Remove temporary debug logging from TextInput.js setLocalRef - Add commented-out Paper blur fix for future testing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5 tasks
Removes the RNTesterPlayground interactive test and the commented-out Paper blur fix to keep the PR focused on Fabric TextInput command fixes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
47ee03f to
c5a26be
Compare
The command dispatch was calling [componentView setGhostText:] unconditionally, but the protocol method is only declared under #if TARGET_OS_OSX. This caused iOS and visionOS builds to fail with "no known instance method for selector". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
Try undo\redo -- e.g.
|
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
TextInput commands (
setGhostText,blur,setSelection) don't work correctly under Fabric on macOS. This PR fixes three issues:setGhostTextcommand to Fabric: Ghost text was implemented for Paper in [iOS/macOS] [TextInput] Implement ghost text #1890 / [iOS/macOS] [TextInput] Implement ghost text #1897 (with undo fixes in Ensure ghost text doesn't appear when performing undos #2105 / [0.73-stable] Ensure ghost text doesn't appear when performing undos #2106), but the Fabric command dispatcher and component view never got the implementation. This ports the ghost text logic (insertion, removal, attributes, delegate cleanup) fromRCTBaseTextInputViewtoRCTTextInputComponentView.blurcommand on macOS Fabric:blurwas a silent no-op because it compared[window firstResponder]against the NSTextField, but on macOS the firstResponder during editing is the field editor (NSTextView), not the text field itself. Fixed by checkingcurrentEditoron NSTextField.textInputDidChangeSelectionto clear ghost text when the user changes selection, matching Paper behavior.setTextAndSelectiondelegate notification: ChangednotifyDelegate:YEStonotifyDelegate:NOto match Paper'ssetSelectionStart:selectionEnd:behavior and prevent spurious delegate callbacks during programmatic selection changes.Test plan
setGhostTextcommand works via RNTester on macOS Fabricblurcommand works on macOS Fabricfocus,clear,setSelectioncommands still work🤖 Generated with Claude Code