Commit eda57a2
fix(macos): TextInput Fabric commands - setGhostText, blur, and selection fixes (#2912)
## Summary
TextInput commands (`setGhostText`, `blur`, `setSelection`) don't work
correctly under Fabric on macOS. This PR fixes three issues:
- **Add missing `setGhostText` command to Fabric**: Ghost text was
implemented for Paper in #1890 / #1897 (with undo fixes in #2105 /
#2106), but the Fabric command dispatcher and component view never got
the implementation. This ports the ghost text logic (insertion, removal,
attributes, delegate cleanup) from `RCTBaseTextInputView` to
`RCTTextInputComponentView`.
- **Fix `blur` command on macOS Fabric**: `blur` was 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 checking
`currentEditor` on NSTextField.
- **Fix ghost text being selectable on Fabric**: Ghost text could be
selected by the user on Fabric (but not Paper). Added cleanup in
`textInputDidChangeSelection` to clear ghost text when the user changes
selection, matching Paper behavior.
- **Fix `setTextAndSelection` delegate notification**: Changed
`notifyDelegate:YES` to `notifyDelegate:NO` to match Paper's
`setSelectionStart:selectionEnd:` behavior and prevent spurious delegate
callbacks during programmatic selection changes.
## Test plan
- [x] Verified `setGhostText` command works via RNTester on macOS Fabric
- [x] Verified `blur` command works on macOS Fabric
- [x] Verified ghost text is not selectable on Fabric
- [x] Verified `focus`, `clear`, `setSelection` commands still work
- [x] JS TextInput tests pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 8fa8f22 commit eda57a2
4 files changed
Lines changed: 191 additions & 6 deletions
File tree
- packages/react-native
- Libraries
- Components/TextInput/__tests__
- Text/TextInput/Multiline
- React/Fabric/Mounting/ComponentViews/TextInput
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
| |||
Lines changed: 13 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
335 | 344 | | |
336 | 345 | | |
337 | 346 | | |
| |||
Lines changed: 154 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
105 | 109 | | |
106 | 110 | | |
107 | 111 | | |
| |||
513 | 517 | | |
514 | 518 | | |
515 | 519 | | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
516 | 524 | | |
517 | 525 | | |
518 | 526 | | |
| |||
537 | 545 | | |
538 | 546 | | |
539 | 547 | | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
540 | 552 | | |
541 | 553 | | |
542 | 554 | | |
| |||
571 | 583 | | |
572 | 584 | | |
573 | 585 | | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
574 | 592 | | |
575 | 593 | | |
576 | 594 | | |
| |||
616 | 634 | | |
617 | 635 | | |
618 | 636 | | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
619 | 648 | | |
620 | 649 | | |
621 | 650 | | |
| |||
631 | 660 | | |
632 | 661 | | |
633 | 662 | | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
634 | 671 | | |
635 | 672 | | |
636 | 673 | | |
| |||
804 | 841 | | |
805 | 842 | | |
806 | 843 | | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
807 | 953 | | |
808 | 954 | | |
809 | 955 | | |
| |||
841 | 987 | | |
842 | 988 | | |
843 | 989 | | |
844 | | - | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
845 | 997 | | |
846 | 998 | | |
847 | 999 | | |
| |||
880 | 1032 | | |
881 | 1033 | | |
882 | 1034 | | |
883 | | - | |
| 1035 | + | |
884 | 1036 | | |
885 | 1037 | | |
886 | 1038 | | |
| |||
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
99 | 119 | | |
100 | 120 | | |
101 | 121 | | |
| |||
0 commit comments