Bug: sheet.setSwipeStep is not a function (causes memory leak)

Please refer to codesandbox

UPDATE: This happens on ListInput with calendar as well: Calendar opens a sheet and the error then show there as well.

After sheet is opened and one resizes the window the following error occurs:

sheet.setSwipeStep is not a function

So I looked into the code and the following is happening:

sheet.on('close', () => {
      currentBreakpointIndex = undefined;
      if (sheet.params.swipeToStep || useBreakpoints) {
        $el.removeClass('modal-in-swipe-step modal-in-breakpoint');
        sheet.emit('local::_swipeStep', false);
        app.off('resize', onResize);
      }
...
}

It only clears the onResize event when the following is set:
sheet.params.swipeToStep || useBreakpoints

However, it sets the event with this code:

sheet.on('open', () => {
      if (sheet.params.closeOnEscape) {
        $(document).on('keydown', onKeyDown);
      }
      $el.prevAll('.popup.modal-in').addClass('popup-behind');
      app.on('resize', onResize);
...
}

Hence it always sets it but when it removes it it only does for a specific use case. The on open code must look like this:

sheet.on('open', () => {
      if (sheet.params.closeOnEscape) {
        $(document).on('keydown', onKeyDown);
      }
      $el.prevAll('.popup.modal-in').addClass('popup-behind');
      if (sheet.params.swipeToStep || useBreakpoints) {
        app.on('resize', onResize); // <= Need to add resize with same conditions as used by the off code
      }
     
...
}
1 Like

Same Problem here.

We are using the f7.smartSelect in combination with the data-open-in="sheet" option.
Sadly after a refresh the resize fails.

Our team tried to destroy the sheet and smartSelect, but the element is still there throwing the error.

Our fix is to use data-open-in="popup" instead of data-open-in="sheet".

Hopefully you can fix this issue. Thanks!

Set sheet to ‘swipeToStep=“false”’ it worked in my case.

Yes that works.

breakpoints: [1],

also works