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

fix(ui5-calendar): keyboard navigation in the picker grid now works properly #2532

Merged
merged 7 commits into from
Dec 3, 2020
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
10 changes: 9 additions & 1 deletion packages/main/src/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,15 @@ class Calendar extends UI5Element {

_handleSelectedDatesChange(event) {
const selectedDates = event.detail.dates;
this.timestamp = selectedDates[selectedDates.length - 1];

// Deselecting a date in multiple selection type
if (this.selection === CalendarSelection.Multiple && this.selectedDates.length > selectedDates.length) {
const deselectedDates = this.selectedDates.filter(timestamp => !selectedDates.includes(timestamp));
this.timestamp = deselectedDates[0];
} else {
this.timestamp = selectedDates[selectedDates.length - 1];
}

this.selectedDates = [...selectedDates];
this.fireEvent("selected-dates-change", { dates: selectedDates });
}
Expand Down
19 changes: 19 additions & 0 deletions packages/main/test/specs/Calendar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,25 @@ describe("Calendar general interaction", () => {
assert.deepEqual(selectedDates, [971136000, 971222400, 971308800], "Change event is fired with proper data");
});

it("Keyboard navigation works properly, when calendar selection type is set to 'Multiple'", () => {
const toggleButton = browser.$("#weekNumbersButton");
const calendar = browser.$("#calendar1");
calendar.setAttribute("selection", "Multiple");
calendar.setAttribute("timestamp", new Date(Date.UTC(2000, 9, 10, 0, 0, 0)).valueOf() / 1000);

toggleButton.click();
toggleButton.click();
browser.keys("Tab");
// Select the focused date
browser.keys("Space");

// Deselect the focused date
browser.keys("Space");
browser.keys("ArrowRight");

assert.ok(calendar.shadow$("ui5-daypicker").shadow$(`[data-sap-timestamp="971222400"]`).isFocusedDeep(), "Focus is properly set");
});

it("Calendar with 'Range' selection type", () => {
const calendar = browser.$("#calendar1");
calendar.setAttribute("timestamp", new Date(Date.UTC(2000, 9, 10, 0, 0, 0)).valueOf() / 1000);
Expand Down