Skip to content

Add option to hide context menu for TextInput #17335 - #18125

Closed
amhinson wants to merge 7 commits into
react:masterfrom
amhinson:add-context-menu-control
Closed

amhinson wants to merge 7 commits into
react:masterfrom
amhinson:add-context-menu-control

Conversation

@amhinson

Copy link
Copy Markdown
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

react/react-native-website#95

Release Notes

[FEATURE][TextInput] - Added contextMenuHidden property

@amhinson

Copy link
Copy Markdown
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

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

Copy link
Copy Markdown
Contributor

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

Balasnest commented Mar 6, 2018 •

Copy link
Copy Markdown

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

@Balasnest

Copy link
Copy Markdown

In which react-native version this works?

@amhinson

amhinson commented Mar 6, 2018

Copy link
Copy Markdown
Contributor Author

This hasn’t been included in a release yet.

@hramos

hramos commented Mar 6, 2018 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown

@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

amhinson commented Nov 6, 2018

Copy link
Copy Markdown
Contributor Author

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

@d2luu

d2luu commented Mar 26, 2019 •

Copy link
Copy Markdown

@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
Copy Markdown
Contributor Author

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

@jeniasaigak

jeniasaigak commented Dec 2, 2019 •

Copy link
Copy Markdown

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