Skip to content

Commit 42418ba

Browse files
committed
fix: fix dp test
1 parent 3edec0a commit 42418ba

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

packages/main/src/DayPicker.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ class DayPicker extends CalendarPart implements ICalendarPicker {
413413
return document.activeElement !== this._focusableDay && this._specialCalendarDates.length === 0;
414414
}
415415

416+
async _onfocusin() {
417+
await renderFinished();
418+
this._focusCorrectDay();
419+
}
420+
416421
/**
417422
* Tells if the day is selected (dark blue).
418423
* @param timestamp
@@ -745,13 +750,16 @@ class DayPicker extends CalendarPart implements ICalendarPicker {
745750
* @param preserveDate whether to preserve the day of the month (f.e. 15th of March + 1 month = 15th of April)
746751
* @private
747752
*/
748-
_modifyTimestampBy(amount: number, unit: string, preserveDate?: boolean) {
753+
async _modifyTimestampBy(amount: number, unit: string, preserveDate?: boolean) {
749754
// Modify the current timestamp
750755
this._safelyModifyTimestampBy(amount, unit, preserveDate);
751756
this._updateSecondTimestamp();
752757

753758
// Notify the calendar to update its timestamp
754759
this.fireDecoratorEvent("navigate", { timestamp: this.timestamp! });
760+
761+
await renderFinished();
762+
this._focusCorrectDay();
755763
}
756764

757765
/**

packages/main/src/MonthPicker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,16 @@ class MonthPicker extends CalendarPart implements ICalendarPicker {
366366
* @param preserveDate whether to preserve the day of the month (f.e. 15th of March + 1 month = 15th of April)
367367
* @private
368368
*/
369-
_modifyTimestampBy(amount: number, preserveDate?: boolean) {
369+
async _modifyTimestampBy(amount: number, preserveDate?: boolean) {
370370
// Modify the current timestamp
371371
this._safelyModifyTimestampBy(amount, "month", preserveDate);
372372
this._updateSecondTimestamp();
373373

374374
// Notify the calendar to update its timestamp
375375
this.fireDecoratorEvent("navigate", { timestamp: this.timestamp! });
376+
377+
await renderFinished();
378+
this._focusCorrectMonth();
376379
}
377380

378381
_onkeyup(e: KeyboardEvent) {

packages/main/src/YearPicker.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
22
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
3+
import query from "@ui5/webcomponents-base/dist/decorators/query.js";
34
import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
45
import i18n from "@ui5/webcomponents-base/dist/decorators/i18n.js";
6+
import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
57
import type LocaleT from "sap/ui/core/Locale";
68
import DateFormat from "@ui5/webcomponents-localization/dist/DateFormat.js";
79
import {
@@ -133,13 +135,21 @@ class YearPicker extends CalendarPart implements ICalendarPicker {
133135

134136
_firstYear?: number;
135137

138+
@query("[data-sap-focus-ref]")
139+
_focusableYear!: HTMLElement;
140+
136141
@i18n("@ui5/webcomponents")
137142
static i18nBundle: I18nBundle;
138143

139144
get roleDescription() {
140145
return YearPicker.i18nBundle.getText(YEAR_PICKER_DESCRIPTION);
141146
}
142147

148+
async _onfocusin() {
149+
await renderFinished();
150+
this._focusableYear.focus();
151+
}
152+
143153
onBeforeRendering() {
144154
if (this._hidden) {
145155
return;
@@ -342,13 +352,16 @@ class YearPicker extends CalendarPart implements ICalendarPicker {
342352
* @param amount
343353
* @private
344354
*/
345-
_modifyTimestampBy(amount: number) {
355+
async _modifyTimestampBy(amount: number) {
346356
// Modify the current timestamp
347357
this._safelyModifyTimestampBy(amount, "year");
348358
this._updateSecondTimestamp();
349359

350360
// Notify the calendar to update its timestamp
351361
this.fireDecoratorEvent("navigate", { timestamp: this.timestamp! });
362+
363+
await renderFinished();
364+
this._focusableYear.focus();
352365
}
353366

354367
_onkeyup(e: KeyboardEvent) {

packages/main/src/YearRangePicker.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
22
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
3+
import query from "@ui5/webcomponents-base/dist/decorators/query.js";
34
import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
45
import i18n from "@ui5/webcomponents-base/dist/decorators/i18n.js";
6+
import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
57
import type LocaleT from "sap/ui/core/Locale";
68
import DateFormat from "@ui5/webcomponents-localization/dist/DateFormat.js";
79
import {
@@ -128,13 +130,21 @@ class YearRangePicker extends CalendarPart implements ICalendarPicker {
128130

129131
_gridStartYear?: number;
130132

133+
@query("[data-sap-focus-ref]")
134+
_focusableYearRange!: HTMLElement;
135+
131136
@i18n("@ui5/webcomponents")
132137
static i18nBundle: I18nBundle;
133138

134139
get roleDescription() {
135140
return YearRangePicker.i18nBundle.getText(YEAR_RANGE_PICKER_DESCRIPTION);
136141
}
137142

143+
async _onfocusin() {
144+
await renderFinished();
145+
this._focusableYearRange.focus();
146+
}
147+
138148
onBeforeRendering() {
139149
if (this._hidden) {
140150
return;
@@ -488,13 +498,16 @@ class YearRangePicker extends CalendarPart implements ICalendarPicker {
488498
* @param amount
489499
* @private
490500
*/
491-
_modifyTimestampBy(amount: number) {
501+
async _modifyTimestampBy(amount: number) {
492502
// Modify the current timestamp
493503
const amountInYears = amount * this._getRangeSize();
494504
this._safelyModifyTimestampBy(amountInYears, "year");
495505

496506
// Notify the calendar to update its timestamp
497507
this.fireDecoratorEvent("navigate", { timestamp: this.timestamp! });
508+
509+
await renderFinished();
510+
this._focusableYearRange.focus();
498511
}
499512

500513
_modifyGridStartBy(years: number) {

0 commit comments

Comments
 (0)