Closed AdrianFahrbach closed 5 months ago
I highly doubt your AppDelegate has anything to do with it. I wonder if there's an Info.plist value you need to allow copy/paste? (I also doubt that...). Without a way to repro it, I'm not sure I can help further though :(
Can you put breakpoints inside classes like RCTUITextView
for pasting and see if they're hit? Or perhaps see if onPaste
is hit in JS?
I highly doubt your AppDelegate has anything to do with it. I wonder if there's an Info.plist value you need to allow copy/paste? (I also doubt that...). Without a way to repro it, I'm not sure I can help further though :(
Can you put breakpoints inside classes like
RCTUITextView
for pasting and see if they're hit? Or perhaps see ifonPaste
is hit in JS?
I sadly don't really know where to put the breakpoints inside the Objective-C files π
The TextInput component doesn't have a onPaste
prop, as far as I know that is "replaced" by onChangeText
and that one doesn't trigger.
The repo in question is this one. It has a branch called text-input-issues
where the App.tsx
is basically only a TextInput
. Maybe this helps you with debugging although I totally understand if you don't have time to take a look at some random repo online!
There is a macOS specific onPaste
callback, you can see it in RNTester in packages/rn-tester
of this repo.
https://github.com/microsoft/react-native-macos/blob/3d54a1ac5aa1afe93ceeb0b1ed14bbacfe6c8703/packages/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js#L178
Maybe to start, this method? I can't keep track of all the TextInput native classes, that's one of the most complex controls. I'm more curious the code is even getting hit. https://github.com/microsoft/react-native-macos/blob/3d54a1ac5aa1afe93ceeb0b1ed14bbacfe6c8703/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm#L769
There is a macOS specific
onPaste
callback, you can see it in RNTester inpackages/rn-tester
of this repo.
This still does not work for me. I see the TextInputMacOSProps
interface in the node_modules, but searching through the node_modules doesn't show this being used anywhere. I tried importing the TextInput
from react-native-macos
and even renaming my file to .macos.tsx
, but Typescript still wouldn't let me use those props.
I don't know, but maybe this has something to do with it.
Maybe to start, this method? I can't keep track of all the TextInput native classes, that's one of the most complex controls. I'm more curious the code is even getting hit.
This on the other hand did "successfully not work". I tested this using NSLog as seen it the screenshots below. "Backspace" as well as "handle key event" was logged (on those actions), but "Paste" and "handle paste" wasn't. I'm still able to paste code using the right click context menu, that also didn't trigger the logs though.
I found the issue! It is my fault and it is a stupid error as well π
I removed unnecessary items from the main menu, including the edit menu, not knowing that this actually defines the shortcuts and does not just offer another way to use them. It was working in a new project, because the menu wasn't edited there and the error sound that I heard wasn't "This is not possible here" but instead "This shortcut is not defined".
After copying the menu back in from the other default project everything was working as expected. So sorry for the confusion!
That is... quite the find. I had no idea it worked that way π
Environment
Steps to reproduce the bug
<TextInput>
componentExpected Behavior
The regular keyboard shortcuts of macOS should work in the input field.
Actual Behavior
I only hear an error sound, besides that nothing happens. See the video below:
https://github.com/microsoft/react-native-macos/assets/45072099/ecbe33fa-3e83-46f9-a912-b95984b6186c
Reproducible Demo
No response
Additional context
I found a few posts about issues with this in React Native in general and unsuccessfully tried the workarounds there. After seeing this PR with a video of the copy/paste working, I tried the same within the default
App.tsx
of a newly generated project (same versions as mine) and it is working there. That sameApp.tsx
in my project had the issue again though. So this has to be related to my project setup.The only thing that I can think of right now is that there is something wrong with my
AppDelegate.swift
(linked below) since I'm not using the default Objective-C setup and my Objective-C and Swift knowledge is quite limited.So I'm not sure if this is even related to react-native-macos and you can just close this issue if you think that the root cause definitely lies somewhere else. I'm happy for any hints or feedback though. I can also add you to the private repo of the app if you are willing to go that deep (maybe in exchange for a coffee or something like that π ).
AppDelegate.swift
: