MCPcopy Create free account
hub / github.com/UI5/webcomponents / _onHomeOrEnd

Method _onHomeOrEnd

packages/main/src/DayPicker.ts:743–755  ·  view source on GitHub ↗

* Called upon "Home" or "End" - moves the focus to the first or last item in the row. * @param homePressed * @private

(homePressed: boolean)

Source from the content-addressed store, hash-verified

741 * @private
742 */
743 _onHomeOrEnd(homePressed: boolean) {
744 this._weeks.forEach(week => {
745 const _week = week as Array<Day>;
746 const dayInThisWeek = _week.findIndex(item => {
747 const date = CalendarDate.fromTimestamp(parseInt(item.timestamp) * 1000);
748 return date.getMonth() === this._calendarDate.getMonth() && date.getDate() === this._calendarDate.getDate();
749 }) !== -1;
750 if (dayInThisWeek) { // The current day is in this week
751 const index = homePressed ? 1 : 7; // select the first (if Home) or last (if End) day of the week
752 this._setTimestamp(parseInt(_week[index].timestamp));
753 }
754 });
755 }
756
757 /**
758 * Called by the Calendar component.

Callers 1

_onkeydownMethod · 0.95

Calls 4

_setTimestampMethod · 0.95
fromTimestampMethod · 0.80
getMonthMethod · 0.80
getDateMethod · 0.80

Tested by

no test coverage detected