Skip to content

Commit

Permalink
Merge pull request #1936 from oasisprotocol/lw/checkbox-focus
Browse files Browse the repository at this point in the history
Add validation message to required checkbox in ChoosePasswordFields
  • Loading branch information
lukaw3d authored May 24, 2024
2 parents 67dcf59 + 0aa3731 commit a70bdbf
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions .changelog/1936.trivial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add validation message to required checkbox in ChoosePasswordFields
2 changes: 1 addition & 1 deletion src/app/components/AddEscrowForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const AddEscrowForm = memo((props: Props) => {
'This validator is ranked in the top 20 by stake. Please consider delegating to a smaller validator to increase network security and decentralization.',
)}
</Text>
<Text size={isMobile ? 'small' : 'medium'} weight="bold">
<Text weight="bold">
<CheckBox
label={t('account.addEscrow.confirmDelegatingToTop.acknowledge', 'Delegate anyway')}
checked={!showNotice}
Expand Down
1 change: 1 addition & 0 deletions src/app/components/PasswordField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface Props<TFormValue> {
suggestions?: Array<{ label: string; value: any }>
validate?: (password: string, form: TFormValue) => string | undefined
error?: string | false
/** @deprecated Use `validate` */
required?: boolean
showTip: string
hideTip: string
Expand Down
4 changes: 3 additions & 1 deletion src/app/components/Persist/ChoosePasswordFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export function ChoosePasswordFields() {

<FormField
name="profileStorageUndependableAcknowledge"
validate={(value: boolean) =>
value ? undefined : t('persist.createProfile.requiredField', 'This field is required')
}
contentProps={{
border: false,
pad: 'none',
Expand All @@ -70,7 +73,6 @@ export function ChoosePasswordFields() {
>
<CheckBox
name="profileStorageUndependableAcknowledge"
required
label={
<Paragraph size="small" fill>
{t(
Expand Down
1 change: 0 additions & 1 deletion src/app/components/Persist/ChoosePasswordInputFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export function ChoosePasswordInputFields({
validate={value =>
value ? undefined : t('persist.loginToProfile.enterPasswordHere', 'Enter your password')
}
required
showTip={t('persist.loginToProfile.showPassword', 'Show password')}
hideTip={t('persist.loginToProfile.hidePassword', 'Hide password')}
width="medium"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ exports[`<Account /> should match snapshot 1`] = `
.c3:hover input:not([disabled]) + div,
.c3:hover input:not([disabled]) + span {
border-color: #000000;
border-color: #00A9FF;
}
.c6 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export const UpdatePassword = () => {
<Form<FormValue>
onSubmit={onSubmit}
{...preventSavingInputsToUserData}
onChange={nextValue => setValue(nextValue)}
onChange={nextValue => {
dispatch(persistActions.resetWrongPassword())
setValue(nextValue)
}}
value={value}
>
<label htmlFor="currentPassword">{t('toolbar.profile.password.title', 'Set a new password')}</label>
Expand All @@ -73,7 +76,6 @@ export const UpdatePassword = () => {
value ? undefined : t('toolbar.profile.password.enterCurrent', 'Enter your current password')
}
error={enteredWrongPassword ? t('persist.loginToProfile.wrongPassword', 'Wrong password') : false}
required
showTip={t('persist.loginToProfile.showPassword', 'Show password')}
hideTip={t('persist.loginToProfile.hidePassword', 'Hide password')}
width="medium"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,6 @@ exports[`<Profile /> should render unavailable state 1`] = `
id="currentPassword"
name="currentPassword"
placeholder="Current password"
required=""
spellcheck="false"
type="password"
value=""
Expand Down Expand Up @@ -690,7 +689,6 @@ exports[`<Profile /> should render unavailable state 1`] = `
id="password1"
name="password1"
placeholder="New password"
required=""
spellcheck="false"
type="password"
value=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ exports[`<CreateWalletPage /> should match snapshot 1`] = `
.c22:hover input:not([disabled]) + div,
.c22:hover input:not([disabled]) + span {
border-color: #000000;
border-color: #00A9FF;
}
.c25 {
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@
"createProfile": {
"passwordMismatch": "Entered password does not match",
"repeatPassword": "Confirm your password",
"requiredField": "This field is required",
"startPersisting": "Store your private keys locally and protect them with a password by creating a profile.",
"startPersistingToggle": "Create a profile",
"undependableAcknowledge": "I understand this password and profile do not substitute my mnemonic.",
Expand Down
5 changes: 5 additions & 0 deletions src/styles/theme/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ const grommetCustomTheme: ThemeType = {
border: {
color: 'text',
},
hover: {
border: {
color: 'focus',
},
},
gap: '1.5ex',
extend: css`
font-size: 14px;
Expand Down

0 comments on commit a70bdbf

Please sign in to comment.