Improve focus control of radioSelect

Makes focus shift to the first time in the range
when you select a day.

Also rewrites the code for controlling focus so it
explains itself better, now it has different
settings.
This commit is contained in:
Tom Byers
2021-01-19 14:12:29 +00:00
parent e7291ffd51
commit 9651da1292
2 changed files with 31 additions and 8 deletions

View File

@@ -228,9 +228,9 @@ describe('RadioSelect', () => {
});
test("keep focus on the default time slot", () => {
test("focus the first time slot", () => {
expect(document.activeElement).toBe(document.getElementById('scheduled_for-0'));
expect(document.activeElement).toBe(document.getElementById('scheduled_for-1'));
});
@@ -347,6 +347,14 @@ describe('RadioSelect', () => {
})
test("focus the selected option", () => {
selectedOption = document.querySelector('.radio-select__column:nth-child(2) input[checked=checked]');
expect(document.activeElement).toBe(selectedOption);
});
});
describe("selecting an option with the enter key should", () => {
@@ -398,6 +406,14 @@ describe('RadioSelect', () => {
})
test("focus the selected option", () => {
selectedOption = document.querySelector('.radio-select__column:nth-child(2) input[checked=checked]');
expect(document.activeElement).toBe(selectedOption);
});
});
test("clicking the 'Done' button should choose whatever time is selected", () => {