Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onPaste to TextInput #45425

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft

Add onPaste to TextInput #45425

wants to merge 20 commits into from

Conversation

s77rt
Copy link
Contributor

@s77rt s77rt commented Jul 13, 2024

Summary:

Detect Paste event. In our use case this is needed to unlock the possibility to support image pasting.

Changelog:

[GENERAL] [ADDED] - Add onPaste prop to TextInput component

Test Plan:

  1. Open RNTester
  2. Go to TextInput > Event handling
  3. Paste clipboard content
  4. Verify onPaste is logged before onChange
  5. Go to TextInput > Pasteboard
  6. Paste clipboard content
  7. Verify the clipboard content is displayed
iOS Android
Screen.Recording.2024-07-13.at.7.08.40.PM.mov
Screen.Recording.2024-07-21.at.3.40.31.PM.mov
Screen.Recording.2024-07-25.at.6.16.22.PM.mov
Screen.Recording.2024-07-25.at.6.28.29.PM.mov

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 13, 2024
@s77rt
Copy link
Contributor Author

s77rt commented Jul 13, 2024

PR for docs update: facebook/react-native-website#4161

@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 13, 2024
@analysis-bot
Copy link

analysis-bot commented Jul 13, 2024

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 21,367,709 +12,853
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 24,564,442 +14,451
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: fcd526d
Branch: main

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @s77rt, thanks for this contributions.

I see that there are some failures in CI for the JS side. This is happening because there is a new method in the spec and this is changing the public API of the component. We have a check that warn us about API changes.

In this case is a safe change, but can you update the test case? The failure is here.

Also, to set expectation, this kind of changes, that touches at the same time JS and native code, can take a little more to be merged and we might have to split the JS part from the Native part to land them properly.

@s77rt
Copy link
Contributor Author

s77rt commented Jul 15, 2024

@cipolleschi Updated! Thanks!

@s77rt s77rt requested a review from cipolleschi July 15, 2024 10:42
@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@cipolleschi
Copy link
Contributor

Hi @s77rt, we were evaluating the PR internally and we figured a couple of things:

  1. This change is for the Old Architecture only. Would it be possible to implement it for the New Architecture also?
  2. This is a new feature that was missing from React Native. Being a new feature, the right approach would have been to first open a proposal in this repo and then, after the suggestions/questions from the core team and other main partners, work on the PR. Would it be possible for you to sketch a proposal as a PR in that repo?

Thank you so much for your patience.

@s77rt
Copy link
Contributor Author

s77rt commented Jul 18, 2024

@cipolleschi Thanks for your quick actions on this.

Would it be possible to implement it for the New Architecture also?

The new arch is already supported and tested with RNTester. Can you please elaborate if I'm missing something here?

Would it be possible for you to sketch a proposal as a PR in that repo?

Sure! react-native-community/discussions-and-proposals#804

@s77rt s77rt marked this pull request as draft July 23, 2024 23:05
@s77rt
Copy link
Contributor Author

s77rt commented Jul 23, 2024

Making this a draft until we land on an approved proposal react-native-community/discussions-and-proposals#804

@huhuanming
Copy link

will there be any new progress? 😳

@s77rt
Copy link
Contributor Author

s77rt commented Aug 23, 2024

@huhuanming Code-wise this is ready. You can port this as a patch for your needs. Feedback is much appreciated. For now this is still marked as draft because there is no approval on the proposal yet (and code could change)

Comment on lines +187 to +188
NSString *fileName = [NSString stringWithFormat:@"%@.%@", [[NSUUID UUID] UUIDString], fileExtension];
NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with RCTTempFilePath

Comment on lines +241 to +242
NSString *fileName = [NSString stringWithFormat:@"%@.%@", [[NSUUID UUID] UUIDString], fileExtension];
NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants