Skip to content
New issue

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

Add validation message to required checkbox in ChoosePasswordFields #1936

Merged
merged 5 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this prop in ChoosePasswordInputFields password1 field too so validation is consistent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as long as it works everywhere. looks like it's used in more than one place.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 removed

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
Loading