Skip to content

feat(ios): textfield option to disable iOS autofill strong password handling - #8348

Merged
vtrifonov merged 2 commits into
NativeScript:masterfrom
NathanWalker:feature/ios-textfield-secure-autofill-handling
Mar 23, 2020
Merged

vtrifonov merged 2 commits into
NativeScript:masterfrom
NathanWalker:feature/ios-textfield-secure-autofill-handling

Conversation

@NathanWalker

@NathanWalker NathanWalker commented Feb 16, 2020

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

This issue has been complained about in a variety of development circles even outside NativeScript and something we recently experienced as a problem on an app we were building.

Here's a few extensive discussions on the topic all of which offer several solutions:

None worked as reliably and bulletproof as the suggestion made in this answer:
expo/expo#2571 (comment)

What is the new behavior?

When an app desires to completely avoid the auto iOS strong password suggestion handling, developers can now specify secureWithoutAutofill="true" vs. the standard secure="true" property.

Currently developers may use TextField as follows which may unexpectedly display the iOS autofill strong password suggestion:

<TextField secure="true"></TextField>

Now developers can specify this new property as follows in areas of their app in which they know various input controls should not display such handling on iOS:

<TextField secureWithoutAutofill="true"></TextField>

Here's a sample of what this iOS UI looks like for those that may not have encountered this before. For those that have with no idea how to completely disable (iOS does not offer an easy way to turn this off other than adjusting a device setting for the app on per user basis), this provides an easy way to guarantee iOS will not display this surprising and often unexpected experience.
IMG_2552

@cla-bot cla-bot Bot added the cla: yes label Feb 16, 2020
@NativeScript NativeScript deleted a comment from dtopuzov Mar 18, 2020
@vtrifonov

Copy link
Copy Markdown
Contributor

@NathanWalker would you, please, run npm run api-extractor and commit the NativeScript/api-reports/NativeScript.api.md after that.

@NathanWalker

Copy link
Copy Markdown
Contributor Author

@vtrifonov Api report committed now thanks 👍

@NathanWalker
NathanWalker force-pushed the feature/ios-textfield-secure-autofill-handling branch from 9c5d419 to 5634b64 Compare March 23, 2020 02:37
@dtopuzov

Copy link
Copy Markdown
Contributor

test

@vtrifonov
vtrifonov merged commit 42fc4ac into NativeScript:master Mar 23, 2020
NathanWalker added a commit that referenced this pull request Aug 7, 2020
…andling (#8348)

* feat(ios): textfield option to disable autofill strong password handling

* chore: api change report
@labordem

labordem commented Dec 7, 2023

Copy link
Copy Markdown

Hello, this option doesn't seem to work anymore, here my code (Nativescript 8.6.1, @nativescript/angular@16.0.0) :

<TextField
      [hint]="'auth.signin.hint-password' | L"
      autocorrect="false"
      autocapitalizationType="none"
      [(ngModel)]="input.password"
      required
      type="password"
      returnKeyType="done"
      [secure]="isPasswordHidden"
      [secureWithoutAutofill]="true"
></TextField>

iOS strong password suggestion appears even with this option.

EDIT:
How to disable TextField password generation on iOS :

.component.html

<TextField
      [hint]="'auth.signin.hint-password' | L"
      autocorrect="false"
      autocapitalizationType="none"
      [(ngModel)]="input.password"
      required
      type="password"
      returnKeyType="done"
      [secure]="isPasswordHidden"
      [secureWithoutAutofill]="true"
      (loaded)="onPasswordTextFieldLoaded($event)"
></TextField>

.component.ts

import { EventData, isIOS, TextField } from '@nativescript/core';

/**
 * Disable secure password proposition on iOS.
 */
onPasswordTextFieldLoaded(args: EventData): void {
    const textField = <TextField>args.object;
    if (isIOS) {
        const uiTextField = <UITextField>textField.ios;
        uiTextField.textContentType = UITextContentTypeOneTimeCode;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants