Skip to content

Commit

Permalink
fix(ui5-daterange-picker): fix js error when removed from the DOM (#2180
Browse files Browse the repository at this point in the history
)
  • Loading branch information
fifoosid authored Sep 4, 2020
1 parent 5193cbe commit 6cb2a71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/main/src/DatePickerPopover.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
no-stretch
?_hide-header={{_shouldHideHeader}}
@keydown="{{_onkeydown}}"
@ui5-after-close="{{_respPopoverConfig.afterClose}}"
@ui5-before-open="{{_respPopoverConfig.beforeOpen}}"
@ui5-after-open="{{_respPopoverConfig.afterOpen}}"
@ui5-before-close="{{_respPopoverConfig.beforeClose}}"
@ui5-after-close="{{_respPopoverConfig.afterClose}}"
>
{{#if showHeader}}
{{> header}}
Expand Down
6 changes: 4 additions & 2 deletions packages/main/src/DateRangePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class DateRangePicker extends DatePicker {
this._initialRendering = true;
this._oneTimeStampSelected = false; // Used to determine whether the first & last date is the same
this._dayPickerMouseoverHandler = this._itemMouseoverHandler.bind(this);
this._respPopoverConfig.beforeOpen = this.handleBeforeOpen;
this._respPopoverConfig.beforeClose = this.handleBeforeClose;
}

async onAfterRendering() {
Expand All @@ -103,13 +105,13 @@ class DateRangePicker extends DatePicker {
this._initialRendering = false;
}

async onEnterDOM() {
async handleBeforeOpen() {
const daypicker = await this.getDayPicker();
daypicker.addEventListener("item-mouseover", this._dayPickerMouseoverHandler);
daypicker.addEventListener("daypickerrendered", this._keyboardNavigationHandler);
}

async onExitDOM() {
async handleBeforeClose() {
const daypicker = await this.getDayPicker();
daypicker.removeEventListener("item-mouseover", this._dayPickerMouseoverHandler);
daypicker.removeEventListener("daypickerrendered", this._keyboardNavigationHandler);
Expand Down

0 comments on commit 6cb2a71

Please sign in to comment.