Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

[terra-time-input] - Mode changing issue on JAWS and SR fixes #2017

Merged
merged 18 commits into from
Feb 12, 2024

Conversation

PK106552
Copy link
Contributor

@PK106552 PK106552 commented Feb 5, 2024

Summary

What was changed:

  1. Changed Up/Down key functionality same as +/- functionality to make uniform.
  2. Changed input type to number instead of text.
  3. Fixed label reading twice issue in time input.

Why it was changed:

  1. Up/Down key functionality was not same as +/- functionality.
  2. Input type was text.
  3. Label value was reading twice in JAWS.

Testing

This change was tested using:

  • WDIO
  • Jest
  • Visual testing (please attach a screenshot or recording)
  • Other (please describe below)
  • No tests are needed

Reviews

In addition to engineering reviews, this PR needs:

  • UX review
  • Accessibility review
  • Functional review

Additional Details

This PR resolves:

UXPLATFORM-6328


Thank you for contributing to Terra.
@cerner/terra

Before fix :

Screenshot 2024-02-02 at 10 15 42 AM

After Fix :

Screenshot 2024-02-02 at 10 15 20 AM

@@ -436,6 +436,8 @@ TimeUtil.DoubleZeroDigit = '00';

TimeUtil.initialValue = ['0', '00'];

TimeUtil.letterKeycode = [38, 40, 65, 66, 67, 68, 69, 70, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90];
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this array for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Safari browser allows letters when we have type as number, to prevent this we have to check all the letters keyCode

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use regex like this.

        let inputValue = e.target.value;
        let numericValue = inputValue.replace(/[^0-9]/g, '');
        e.target.value = numericValue;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

handleKeyDown event is triggering when we press any letter, so i have added regex check in keyDown event and removed keyCode array value from TimeUtil file

@saket2403
Copy link
Contributor

Left/Right Arrow key not moving the focus between the input fields. Please compare with previous functionality.

@PK106552
Copy link
Contributor Author

PK106552 commented Feb 5, 2024

Left/Right Arrow key not moving the focus between the input fields. Please compare with previous functionality.

The input element's type ('number') does not support setSelectionRange, that's why left and right arrow key is not shifting focus, i'm investigating it.

@rbsree
Copy link

rbsree commented Feb 7, 2024

+1 for Accessibility Review.
The issues mentioned in the PR are fixed now.

  • The input field for the Terra Time Input is implemented as type="number" field.
    The value of the hour or minute field can be changed using the +/- or UP/DOWN arrow key as expected.
  • Hotkey implemented for the Time Input field "N" is also supported as expected, setting the current time as the input.

Issue:

  • When users are provided an input in the time field, the user is not able to navigate between the hour and minute fields using the right/left arrow key. When the field is empty the arrow key navigation is working as expected.
  • The arrow navigation is not a default behavior for , in this case, it has been implemented through the property "setSelectionRange" which works when the input field is empty, but the same is not supported when the "Terra Time Input" field has input defined.
  • This is not a major blocker for users, as user can still navigate through the input field using TAB/SHIFT+TAB key.

Comment on lines 127 to 190
describe('pressing -', () => {
it('should roll over to 11 AM if hour and minute is at 12:00 PM', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/time-input/twelve-hour/filled-evening');
browser.refresh();
Terra.hideInputCaret('#timeInput input[name="terra-time-minute-time-input"]');

$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys('12');
browser.keys('00');
$('#timeInput input[name="terra-time-minute-time-input"]').click();
browser.keys('-');
expect($('#timeInput input[name="terra-time-hour-time-input"]')).toHaveValue('11');
expect($('#timeInput input[name="terra-time-minute-time-input"]')).toHaveValue('59');
validateElement('- causes rollover to morning');
});

it('should roll over to 11 PM if hour and minute is at 12:00 AM', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/time-input/twelve-hour/filled-morning');
browser.refresh();
Terra.hideInputCaret('#timeInput input[name="terra-time-minute-time-input"]');

$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys('12');
browser.keys('00');
$('#timeInput input[name="terra-time-minute-time-input"]').click();
browser.keys('-');
expect($('#timeInput input[name="terra-time-hour-time-input"]')).toHaveValue('11');
expect($('#timeInput input[name="terra-time-minute-time-input"]')).toHaveValue('59');
validateElement('- causes rollover to evening');
});
});

describe('pressing +', () => {
it('should roll over to 12 AM if hour and minute is at 11:59 PM', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/time-input/twelve-hour/filled-evening');
browser.refresh();
Terra.hideInputCaret('#timeInput input[name="terra-time-minute-time-input"]');

$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys('11');
browser.keys('59');
$('#timeInput input[name="terra-time-minute-time-input"]').click();
browser.keys('+');
expect($('#timeInput input[name="terra-time-hour-time-input"]')).toHaveValue('12');
expect($('#timeInput input[name="terra-time-minute-time-input"]')).toHaveValue('00');
validateElement('+ causes rollover to morning');
});

it('should roll over to 12 PM if hour and minute is at 11:59 AM', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/time-input/twelve-hour/filled-morning');
browser.refresh();
Terra.hideInputCaret('#timeInput input[name="terra-time-minute-time-input"]');

$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys('11');
browser.keys('59');
$('#timeInput input[name="terra-time-minute-time-input"]').click();
browser.keys('+');
expect($('#timeInput input[name="terra-time-hour-time-input"]')).toHaveValue('12');
expect($('#timeInput input[name="terra-time-minute-time-input"]')).toHaveValue('00');
validateElement('+ causes rollover to evening');
});
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these tests removed? Instead the click events before pressing +/- should be updated so that they match the expected output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@PK106552 PK106552 requested a review from saket2403 February 7, 2024 12:16
Comment on lines 30 to 89
it('displays twelve hour meridiem - Up Arrow on hour does not change meridiem', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/time-input/twelve-hour/default');
browser.refresh();
Terra.hideInputCaret('#timeInput input[name="terra-time-hour-time-input"]');

$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys(['ArrowUp']);
validateRoot('up arrow does not change meridiem');
});

it('displays twelve hour - Changes time to 01 when up is pressed on hour of 12', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/time-input/twelve-hour/default');
browser.refresh();
Terra.hideInputCaret('#timeInput input[name="terra-time-hour-time-input"]');

$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys('12');
$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys(['ArrowUp']);
validateRoot('up arrow changes time to 01');
});

it('displays twelve hour - Changes time to 12 when down is pressed on hour of 01', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/time-input/twelve-hour/default');
browser.refresh();
Terra.hideInputCaret('#timeInput input[name="terra-time-hour-time-input"]');

$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys('01');
$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys(['ArrowDown']);

validateRoot('down arrow changes time to 12');
});

it('displays twelve hour meridiem - Switched when up is press on hour of 11', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/time-input/twelve-hour/default');
browser.refresh();
Terra.hideInputCaret('#timeInput input[name="terra-time-hour-time-input"]');

$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys('11');
$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys(['ArrowUp']);

validateRoot('switch meridiem - up arrow');
});

it('displays twelve hour meridiem - Switched when down is press on hour of 12', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/time-input/twelve-hour/default');
browser.refresh();
Terra.hideInputCaret('#timeInput input[name="terra-time-hour-time-input"]');

$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys('12');
$('#timeInput input[name="terra-time-hour-time-input"]').click();
browser.keys(['ArrowDown']);
validateRoot('switch meridiem - down arrow');
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Please update these tests so that they test the newly added functionality of the Up/Down arrow keys instead of removing them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@@ -126,29 +66,28 @@ Terra.describeViewports('Time Input Twelve Hour', ['medium'], () => {

describe('pressing -', () => {
it('should roll over to 11 AM if hour and minute is at 12:00 PM', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/time-input/twelve-hour/filled-evening');
browser.url('/raw/tests/cerner-terra-framework-docs/time-input/twelve-hour/default');
Copy link
Contributor

@saket2403 saket2403 Feb 7, 2024

Choose a reason for hiding this comment

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

Why are these URLs changed what was the issue with the existing url? I can see similar changes in other tests also

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typed input is not rendering If we use filled input field, that's why i have used default empty field test example

Copy link
Contributor

Choose a reason for hiding this comment

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

So that means the existing functionality is breaking. In previous implementation you could type without clearing the field. Please try to fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have verified it, previous implementation is working fine, we can able to edit filled time when we navigate using tab key, but when we click on field using mouse that time only we could not able to edit the filled time.

Copy link
Contributor

Choose a reason for hiding this comment

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

So please look into it if that can be fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

event.currentTarget.value = ''; // eslint-disable-line no-param-reassign
}

if (!event.key.match(/^[0-9]/g) && !(event.keyCode === KeyCode.KEY_BACK_SPACE || event.keyCode === KeyCode.KEY_DELETE || event.keyCode === KeyCode.KEY_TAB || event.keyCode === KeyCode.KEY_RIGHT || event.keyCode === KeyCode.KEY_LEFT)) {
Copy link
Contributor

@sugan2416 sugan2416 Feb 9, 2024

Choose a reason for hiding this comment

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

should we not include Up/Down arrows here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need, because automatically Up/Down key will be increase/decrease value when we use type as number in input field

@@ -311,4 +311,10 @@
}
}
}
// stylelint-disable property-no-vendor-prefix
input::-webkit-outer-spin-button,
Copy link
Contributor

Choose a reason for hiding this comment

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

why was this added? Was it to suppress warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This style was included to hide arrow icons in input field when we use type as number, it was to suppress property-no-vendor-prefix warning

@PK106552 PK106552 requested a review from sugan2416 February 9, 2024 10:51
@sugan2416 sugan2416 self-requested a review February 9, 2024 11:23
Comment on lines 772 to 775
const secondsValue = Number($('input[name="terra-time-second-input"]').getValue());
const secondsTimeValue = today.seconds();
const secondsInRange = (secondsTimeValue === secondsValue + 1 || secondsTimeValue === secondsValue);
expect(secondsInRange).toBe(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why has this been removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment on lines 820 to 823
const secondsValue = Number($('input[name="terra-time-second-input"]').getValue());
const secondsTimeValue = today.seconds();
const secondsInRange = (secondsTimeValue === secondsValue + 1 || secondsTimeValue === secondsValue);
expect(secondsInRange).toBe(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why has this been removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment on lines 1181 to 1204
it('should set date to today and now plus 1 seconds in the second input', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/date-time-picker/date-time-picker-with-seconds');
browser.refresh();
$('input[name="terra-time-second-input"]').click();
browser.keys('+');

const today = moment.utc().add(1, 'minutes');
const today = moment.utc().add(1, 'seconds');
expect($('input[name="terra-date-year-input"]')).toHaveValue(today.year().toString());
expect($('input[name="terra-date-month-input"]')).toHaveValue((`0${(today.month() + 1)}`).slice(-2));
expect($('input[name="terra-date-day-input"]')).toHaveValue((`0${today.date()}`).slice(-2));
expect($('input[name="terra-time-hour-input"]')).toHaveValue((`0${today.hour()}`).slice(-2));
expect($('input[name="terra-time-minute-input"]')).toHaveValue((`0${today.minute()}`).slice(-2));
const secondsValue = Number($('input[name="terra-time-second-input"]').getValue());
const secondsTimeValue = today.seconds();
const secondsInRange = (secondsTimeValue === secondsValue + 1 || secondsTimeValue === secondsValue);
expect(secondsInRange).toBe(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

This test says that you are testing +1 sec to the seconds but I cannot see the validation for seconds field here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment on lines 1265 to 1268
const secondsValue = Number($('input[name="terra-time-second-input"]').getValue());
const secondsTimeValue = today.seconds();
const secondsInRange = (secondsTimeValue === secondsValue + 1 || secondsTimeValue === secondsValue);
expect(secondsInRange).toBe(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

This test says that you are testing +1 sec to the seconds but you have removed seconds field validation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@github-actions github-actions bot temporarily deployed to preview-pr-2017 February 9, 2024 16:10 Destroyed
@saket2403 saket2403 merged commit 50c3420 into main Feb 12, 2024
22 checks passed
@saket2403 saket2403 deleted the timeInput_fixes branch February 12, 2024 09:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants