Skip to content

Commit 9bef507

Browse files
authored
Merge pull request #21126 from rezkiy37/fix/19721-protected-pdf-autofill
Fix autofill for a protected PDF file in Safari
2 parents 18d62d0 + 5a23eeb commit 9bef507

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/components/PDFView/PDFPasswordForm.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import compose from '../../libs/compose';
1111
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
1212
import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions';
1313
import shouldDelayFocus from '../../libs/shouldDelayFocus';
14+
import * as Browser from '../../libs/Browser';
15+
import CONST from '../../CONST';
1416

1517
const propTypes = {
1618
/** If the submitted password is invalid (show an error message) */
@@ -104,7 +106,11 @@ class PDFPasswordForm extends Component {
104106
</View>
105107
<TextInput
106108
label={this.props.translate('common.password')}
107-
autoComplete="off"
109+
/**
110+
* This is a workaround to bypass Safari's autofill odd behaviour.
111+
* This tricks the browser not to fill the username somewhere else and still fill the password correctly.
112+
*/
113+
autoComplete={Browser.getBrowser() === CONST.BROWSER.SAFARI ? 'username' : 'off'}
108114
autoCorrect={false}
109115
textContentType="password"
110116
onChangeText={this.updatePassword}

0 commit comments

Comments
 (0)