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

Accessibility improvement in Choose New Password page #7665

Merged
merged 17 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
59 changes: 57 additions & 2 deletions packages/client/src/views/UserSetup/CreatePassword.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('CreatePassword page tests', () => {
component = testComponent
})

it('it shows passwords missmatch error when Continue button is pressed', async () => {
it('it shows passwords missmatch error when Continue button is clicked', async () => {
component.find('input#NewPassword').simulate('change', {
target: { id: 'NewPassword', value: '0crvsPassword' }
})
Expand All @@ -40,7 +40,36 @@ describe('CreatePassword page tests', () => {
'Passwords do not match'
)
})
it('it passes validations', () => {
it('it shows passwords mismatch error when Enter/Return key is pressed on ConfirmPassword field', async () => {
component.find('input#NewPassword').simulate('change', {
target: { id: 'NewPassword', value: '0crvsPassword' }
})
component.find('input#ConfirmPassword').simulate('change', {
target: { id: 'ConfirmPassword', value: 'missmatch' }
})
component.find('input#ConfirmPassword').simulate('keyDown', {
key: 'Enter',
keyCode: 13,
which: 13
})
expect(component.find('#GlobalError').hostNodes().text()).toEqual(
'Passwords do not match'
)
})
it('it shows passwords mismatch error when Enter/Return key is pressed on NewPassword field', async () => {
component.find('input#NewPassword').simulate('change', {
target: { id: 'NewPassword', value: '0crvsPassword' }
})
component.find('input#NewPassword').simulate('keyDown', {
key: 'Enter',
keyCode: 13,
which: 13
})
expect(component.find('#GlobalError').hostNodes().text()).toEqual(
'Passwords do not match'
)
})
it('it passes validations when Continue button is clicked', () => {
HabibSentongo marked this conversation as resolved.
Show resolved Hide resolved
component.find('input#NewPassword').simulate('change', {
target: { id: 'NewPassword', value: '0crvsPassword' }
})
Expand All @@ -49,6 +78,32 @@ describe('CreatePassword page tests', () => {
})
component.find('button#Continue').simulate('click')
})
it('it passes validations when Enter/Return key is pressed on ConfirmPassword field', () => {
component.find('input#NewPassword').simulate('change', {
target: { id: 'NewPassword', value: '0crvsPassword' }
})
component.find('input#ConfirmPassword').simulate('change', {
target: { id: 'ConfirmPassword', value: '0crvsPassword' }
})
component.find('input#ConfirmPassword').simulate('keyDown', {
key: 'Enter',
keyCode: 13,
which: 13
})
})
it('it passes validations when Enter/Return key is pressed on NewPassword field', () => {
component.find('input#NewPassword').simulate('change', {
target: { id: 'NewPassword', value: '0crvsPassword' }
})
component.find('input#ConfirmPassword').simulate('change', {
target: { id: 'ConfirmPassword', value: '0crvsPassword' }
})
component.find('input#NewPassword').simulate('keyDown', {
key: 'Enter',
keyCode: 13,
which: 13
})
})
HabibSentongo marked this conversation as resolved.
Show resolved Hide resolved
it('it shows disabled continue button when no password is given', () => {
expect(
component.find('button#Continue').hostNodes().props().disabled
Expand Down
8 changes: 8 additions & 0 deletions packages/client/src/views/UserSetup/CreatePassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ export function CreatePassword({ setupData, goToStep }: IProps) {
})
}
}
const handleKeyDown = (event: React.KeyboardEvent) => {
if (event.key === 'Enter') {
event.preventDefault()
whatNext()
}
}

const continueActionButton = (
<PrimaryButton
Expand Down Expand Up @@ -169,6 +175,7 @@ export function CreatePassword({ setupData, goToStep }: IProps) {
touched={true}
value={newPassword}
onChange={checkPasswordStrength}
onKeyDown={handleKeyDown}
error={continuePressed && newPassword.length === 0}
/>
</InputField>
Expand Down Expand Up @@ -207,6 +214,7 @@ export function CreatePassword({ setupData, goToStep }: IProps) {
error={continuePressed && passwordMismatched}
value={confirmPassword}
onChange={matchPassword}
onKeyDown={handleKeyDown}
/>
</InputField>
{passwordMismatched && (
Expand Down
Loading