Disable Sheet Modal drag while scrolling the modal content

Hello, I’ve recently upgraded to Ionic 6 and have to have a scrollable area inside of the sheet modal. I don’t have a working example I can share but in the Ionic example component I basically have this highlighted section scrolling within my modal:

The problem is, when I scroll on my emulator, the “drag” event that moves the sheet modal up and down is also activated. So as I scroll the content up or down, the modal itself also moves up and down a bit.

Is there any way to disable the drag events when scrolling interior content in the sheet modal? Or restrict the drag events to just the handle?

I tried canDismiss in my modal controller but that really only keeps it from closing, I can still drag up to the final breakpoint while I’m just scrolling the content.

Any help would be greatly appreciated, thanks!

Found a solution for this if anyone in the future is interested. In the Angular Component I’m using in the Modal Controller, I just grabbed an element inside the template and did the following:

const scrollcontainer = this.element.nativeElement.querySelector(this.scrollContainerClass);

scrollcontainer.ontouchmove = function (e) {
    e.stopPropagation();
};

The stop propagation prevents the touchmove event from bubbling up to the sheet modal just fine. As long as you have areas outside of the scroll container the user can still click on to drag, the sheet modal should still work as desired. I tested it out on iOS and Android emulators and seems to be behaving as I want it to.

Cheers.

2 Likes

thanks for sharing :blush: