Skip to content

Commit

Permalink
fix: remove redundant rerendering logic
Browse files Browse the repository at this point in the history
  • Loading branch information
unazko committed Jan 31, 2025
1 parent 41530f6 commit 9e11659
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions packages/main/src/Calendar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import type UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import type { ChangeInfo, InvalidationInfo } from "@ui5/webcomponents-base/dist/UI5Element.js";
import type { ChangeInfo } from "@ui5/webcomponents-base/dist/UI5Element.js";
import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
Expand Down Expand Up @@ -275,7 +275,7 @@ class Calendar extends CalendarPart {
* @public
* @since 1.23.0
*/
@slot({ type: HTMLElement })
@slot({ type: HTMLElement, invalidateOnChildChange: true })
calendarLegend!: Array<CalendarLegend>;

/**
Expand All @@ -302,23 +302,13 @@ class Calendar extends CalendarPart {
@property()
_selectedItemType: `${CalendarLegendItemType}` = "None";

_onCalendarLegendInvalidateBound: (invalidationInfo: InvalidationInfo) => void;

@i18n("@ui5/webcomponents")
static i18nBundle: I18nBundle;

constructor() {
super();

this._valueIsProcessed = false;
this._onCalendarLegendInvalidateBound = this._onCalendarLegendInvalidate.bind(this);
}

_onCalendarLegendInvalidate(invalidationInfo: InvalidationInfo) {
if (invalidationInfo.reason === "childchange") {
this._specialCalendarDates;
invalidationInfo.target.detachInvalidate(this._onCalendarLegendInvalidateBound);
}
}

/**
Expand Down Expand Up @@ -469,11 +459,6 @@ class Calendar extends CalendarPart {

onBeforeRendering() {
this._normalizeCurrentPicker();
const calendarLegend = this.calendarLegend.length ? this.calendarLegend[0] : undefined;

if (calendarLegend) {
calendarLegend.attachInvalidate(this._onCalendarLegendInvalidateBound);
}

if (!this._valueIsProcessed) {
if (this._selectedDatesTimestamps) {
Expand Down

0 comments on commit 9e11659

Please sign in to comment.