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 option to hide context menu for TextInput #17335 #18125

Closed
wants to merge 7 commits into from

Conversation

amhinson
Copy link
Contributor

Motivation

There is currently no way to disable to context menu that automatically appears over a TextInput. This is especially troublesome if you would like to disable the user from pasting text into certain fields. This PR adds a contextMenuHidden property to TextInput that will hide it.

Test Plan

I'm not sure if testing is necessary here. I would be happy to investigate further on how this would be tested, if deemed necessary!

Related PRs

facebook/react-native-website#95

Release Notes

[FEATURE][TextInput] - Added contextMenuHidden property

@amhinson
Copy link
Contributor Author

@hramos Here is the new PR.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. cla signed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Feb 27, 2018
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@hramos is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@Balasnest
Copy link

Balasnest commented Mar 6, 2018

Its still showing the context menu. I can able to paste into the field. How to disable it?

@Balasnest
Copy link

In which react-native version this works?

@amhinson
Copy link
Contributor Author

amhinson commented Mar 6, 2018

This hasn’t been included in a release yet.

@hramos
Copy link
Contributor

hramos commented Mar 6, 2018

You can always see what release any commit is in by clicking on the link and looking at the tags. This commit landed only 7 days ago, so I wouldn't expect it to be on a stable release until 0.55.

@robinheinze
Copy link

@amhinson Were you able to confirm that this works on Android? I'm using 0.55.4, which includes the new prop, and it works on iOS, but on Android, the context menu still appears when tapping on text in the input.

@amhinson
Copy link
Contributor Author

amhinson commented Nov 6, 2018

@robinheinze I did confirm that it worked on a few Android devices, although maybe some devices behave differently?

@d2luu
Copy link

d2luu commented Mar 26, 2019

@amhinson
Relate to issue @robinheinze mentioned above.
On Android, this not works by double-tap to TextInput field. I read your PR and found that only handle onLongClick case, not on double-tap case. So, the context menu still appears on Android just by double-tap to TextInput field. I'm using 0.57.4 and test on Samsung Note FE, and few other devices too.

@amhinson
Copy link
Contributor Author

Ah good catch! I was definitely only accounting for long press.

@jeniasaigak
Copy link

jeniasaigak commented Dec 2, 2019

Ah good catch! I was definitely only accounting for long press.

@amhinson Can you please add double click handler as the issue still present after almost a year? The solution works perfectly for the long press but not for the double press. Thanks a lot in advance!

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. Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants