Skip to content

fix(fabric): implement missing TextInput commands for macOS#2912

Draft
Saadnajmi wants to merge 1 commit intomicrosoft:mainfrom
Saadnajmi:t3code/fabric-textinput-refs
Draft

fix(fabric): implement missing TextInput commands for macOS#2912
Saadnajmi wants to merge 1 commit intomicrosoft:mainfrom
Saadnajmi:t3code/fabric-textinput-refs

Conversation

@Saadnajmi
Copy link
Copy Markdown
Collaborator

Summary

  • Add setGhostText command to Fabric TextInput — was declared in JS supportedCommands but completely missing from the native Fabric command handler (RCTTextInputNativeCommands.h). Ported full implementation from Paper (RCTBaseTextInputView.mm) with Fabric API adaptations.
  • Fix setTextAndSelection on macOS — changed notifyDelegate:YES to notifyDelegate:NO to match Paper behavior, preventing spurious delegate callbacks during programmatic selection changes from JS.
  • Add ghost text cleanup in delegate methods — strips ghost text in textInputDidChange when user types, preventing ghost text from leaking into JS state.
  • Add debug logging — temporary __DEV__ logging in setLocalRef to help diagnose the reported ref-is-null issue at runtime.
  • Add RNTesterPlayground verification — interactive test case with buttons for all TextInput ref commands (focus, blur, clear, setSelection, setGhostText) and ref status display.

Test plan

  • Build macOS RNTester with Fabric, navigate to Playgrounds → Playground
  • Verify "Ref status" shows "REF OK" (not "REF IS NULL")
  • Test each button: Focus, Blur, Clear, Set Selection (0,5), Set Ghost Text, Clear Ghost Text
  • Verify typing into TextInput clears active ghost text
  • Verify setSelection sets selection without triggering extra selection change events
  • Run jest TextInput-test.js — new assertions for setSelection and setGhostText instance methods
  • Remove debug logging in TextInput.js before merging

🤖 Generated with Claude Code

- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant