| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -13,7 +13,6 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate { | |
| public static ObjCProtocols = [UITextFieldDelegate]; | ||
|
|
||
| private _owner: WeakRef<TextField>; | ||
| private firstEdit: boolean; | ||
|
|
||
| public static initWithOwner(owner: WeakRef<TextField>): UITextFieldDelegateImpl { | ||
| const delegate = <UITextFieldDelegateImpl>UITextFieldDelegateImpl.new(); | ||
| Expand Down Expand Up | @@ -125,6 +124,7 @@ export class TextField extends TextFieldBase { | |
| super.initNativeView(); | ||
| this._delegate = UITextFieldDelegateImpl.initWithOwner(new WeakRef(this)); | ||
| this.nativeViewProtected.delegate = this._delegate; | ||
| this._applySecureWithoutAutofillTraits(this.nativeViewProtected); | ||
| } | ||
|
|
||
| disposeNativeView() { | ||
| Expand All | @@ -140,6 +140,7 @@ export class TextField extends TextFieldBase { | |
|
|
||
| public textFieldShouldBeginEditing(textField: UITextField): boolean { | ||
| this._firstEdit = true; | ||
| this._applySecureWithoutAutofillTraits(textField); | ||
|
|
||
| return this.editable; | ||
| } | ||
| Expand Down Expand Up | @@ -174,14 +175,7 @@ export class TextField extends TextFieldBase { | |
| } | ||
|
|
||
| public textFieldShouldChangeCharactersInRangeReplacementString(textField: UITextField, range: NSRange, replacementString: string): boolean { | ||
| if (this.secureWithoutAutofill && !textField.secureTextEntry) { | ||
| /** | ||
| * Helps avoid iOS 12+ autofill strong password suggestion prompt | ||
| * Discussed in several circles but for example: | ||
| * https://github.com/expo/expo/issues/2571#issuecomment-473347380 | ||
| */ | ||
| textField.secureTextEntry = true; | ||
| } | ||
| this._applySecureWithoutAutofillTraits(textField); | ||
| const delta = replacementString.length - range.length; | ||
| if (delta > 0) { | ||
| if (textField.text.length + delta > this.maxLength) { | ||
| Expand Down Expand Up | @@ -243,6 +237,44 @@ export class TextField extends TextFieldBase { | |
| } | ||
| [secureProperty.setNative](value: boolean) { | ||
| this.nativeTextViewProtected.secureTextEntry = value; | ||
| this._applySecureWithoutAutofillTraits(this.nativeTextViewProtected); | ||
| } | ||
|
|
||
| private _applySecureWithoutAutofillTraits(textField: UITextField): void { | ||
| if (!textField || !this.secureWithoutAutofill) { | ||
| return; | ||
| } | ||
|
|
||
| const nativeField = textField as any; | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIs cast to any necessary here? I understand these props are available in UITextField.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySome properties are sdk level scoped so we can probably rather use SDK_VERSION scope on some.
Sorry, something went wrong.
All reactions
|
||
|
|
||
| textField.secureTextEntry = true; | ||
|
|
||
| if (nativeField.textContentType !== undefined) { | ||
| nativeField.textContentType = typeof UITextContentTypeOneTimeCode !== 'undefined' ? UITextContentTypeOneTimeCode : ''; | ||
| } | ||
|
|
||
| if (nativeField.autocorrectionType !== undefined) { | ||
| nativeField.autocorrectionType = UITextAutocorrectionType.No; | ||
| } | ||
| if (nativeField.spellCheckingType !== undefined) { | ||
| nativeField.spellCheckingType = UITextSpellCheckingType.No; | ||
| } | ||
| if (nativeField.smartDashesType !== undefined) { | ||
| nativeField.smartDashesType = UITextSmartDashesType.No; | ||
| } | ||
| if (nativeField.smartQuotesType !== undefined) { | ||
| nativeField.smartQuotesType = UITextSmartQuotesType.No; | ||
| } | ||
| if (nativeField.smartInsertDeleteType !== undefined) { | ||
| nativeField.smartInsertDeleteType = UITextSmartInsertDeleteType.No; | ||
| } | ||
| if (nativeField.passwordRules !== undefined) { | ||
| nativeField.passwordRules = null; | ||
| } | ||
|
|
||
| if (nativeField.reloadInputViews) { | ||
| nativeField.reloadInputViews(); | ||
| } | ||
| } | ||
|
|
||
| [colorProperty.getDefault](): { textColor: UIColor; tintColor: UIColor } { | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityMaybe we need an extra flag to determine if the native props have already been updated and reduce _applySecureWithoutAutofillTraits calls since there are cases like reloadInputViews() that might be called multiple times while typing.
For instance, the old fix made sure to check whether secureTextEntry was already enabled or not before proceeding.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.