Skip to content

Commit

Permalink
fix(ui5-calendar): adjust year button visibility (#9328)
Browse files Browse the repository at this point in the history
Fixes: #9107
  • Loading branch information
unazko authored Jun 27, 2024
1 parent 92ec9d4 commit 3b61360
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/main/src/Calendar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
.isPrevButtonDisabled="{{_previousButtonDisabled}}"
.isNextButtonDisabled="{{_nextButtonDisabled}}"
.isMonthButtonHidden="{{_isHeaderMonthButtonHidden}}"
.isYearButtonHidden="{{_isHeaderYearButtonHidden}}"
._monthButtonText="{{_headerMonthButtonText}}"
._yearButtonText="{{_headerYearButtonText}}"
._yearButtonTextSecType="{{_headerYearButtonTextSecType}}"
Expand Down
8 changes: 8 additions & 0 deletions packages/main/src/Calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,14 @@ class Calendar extends CalendarPart {
return this._currentPicker === "month" || this._currentPicker === "year";
}

/**
* The year button is hidden when the year picker is shown
* @private
*/
get _isHeaderYearButtonHidden(): boolean {
return this._currentPicker === "year";
}

get _isDayPickerHidden() {
return this._currentPicker !== "day";
}
Expand Down
12 changes: 12 additions & 0 deletions packages/main/test/specs/Calendar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,4 +431,16 @@ describe("Calendar general interaction", () => {

assert.ok(await currentDayItem.isFocusedDeep(), "Current calendar day item is focused");
});

it("Calendar header buttons visibility", async () => {
const calendarHeader = await browser.$("#calendar1").shadow$("ui5-calendar-header");
const monthButton = await calendarHeader.shadow$(`[data-ui5-cal-header-btn-month]`);
const yearButton = await calendarHeader.shadow$(`[data-ui5-cal-header-btn-year]`);

await monthButton.click();
assert.ok(monthButton.hasAttribute("hidden"), "The month button is hidden");

await yearButton.click();
assert.ok(yearButton.hasAttribute("hidden"), "The year button is hidden");
});
});

0 comments on commit 3b61360

Please sign in to comment.