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

Disable Autocomplete in shortcode block #19848

Merged
merged 5 commits into from
Jan 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/block-library/src/shortcode/edit.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { View, Text } from 'react-native';
import { Platform, View, Text } from 'react-native';

/**
* WordPress dependencies
Expand Down Expand Up @@ -36,6 +36,14 @@ export function ShortcodeEdit( props ) {
isSelected={ props.isSelected }
onFocus={ onFocus }
onBlur={ onBlur }
autoCorrect={ false }
autoComplete="off"
/*
* For some devices autoCorrect and autoComplete are not enough to hide the suggestion toolbar.
* Following the suggestion below we added the keyboard type as well.
* https://stackoverflow.com/questions/37001070/how-to-avoid-the-suggestions-of-keyboard-for-android-in-react-native/51411575#51411575
*/
keyboardType={ Platform.OS === 'ios' ? 'default' : 'visible-password' }
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for the visible-password here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my testing, I found autoCorrect={ false } and autoComplete="off" only worked on some devices (not my pixel, for example), so I found this post that suggested creating a specific class or adding this flag.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah thanks. I don't love it, but if that's what it takes to make it work...
Could you add that as a comment in the code so it's clearer in the future?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding the comment, and yep it's sad to have to do these kind of workaround :/.

placeholderTextColor={ placeholderStyle.color }
/>
</View>
Expand Down