Skip to content

Commit

Permalink
clarify types of PDFPasswordForm
Browse files Browse the repository at this point in the history
  • Loading branch information
rezkiy37 committed Dec 6, 2023
1 parent ea3c5c0 commit 9ad9d67
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/PDFPasswordForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {isSafari} from './helpers';
type Props = {
isPasswordInvalid: boolean;
isFocused: boolean;
onSubmit: (password: string) => void;
onPasswordChange: (password: string) => void;
onPasswordFieldFocus: (isFocused: boolean) => void;
onSubmit?: (password: string) => void;
onPasswordChange?: (password: string) => void;
onPasswordFieldFocus?: (isFocused: boolean) => void;
};

const propTypes = {
Expand Down Expand Up @@ -59,7 +59,7 @@ function PDFPasswordForm({isPasswordInvalid, isFocused, onSubmit, onPasswordChan
const newPassword = event.target.value;

setPassword(newPassword);
onPasswordChange(newPassword);
onPasswordChange?.(newPassword);
setValidationErrorText('');
};

Expand All @@ -82,7 +82,7 @@ function PDFPasswordForm({isPasswordInvalid, isFocused, onSubmit, onPasswordChan
return;
}

onSubmit(password);
onSubmit?.(password);
};

const validateAndNotifyPasswordBlur = () => {
Expand Down Expand Up @@ -137,7 +137,7 @@ function PDFPasswordForm({isPasswordInvalid, isFocused, onSubmit, onPasswordChan
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={isFocused}
type="password"
onFocus={() => onPasswordFieldFocus(true)}
onFocus={() => onPasswordFieldFocus?.(true)}
onBlur={validateAndNotifyPasswordBlur}
onChange={updatePassword}
/>
Expand Down

0 comments on commit 9ad9d67

Please sign in to comment.