MudBlazor.StaticInput icon indicating copy to clipboard operation
MudBlazor.StaticInput copied to clipboard

MudDrawer with ClipMode.Never Does Not Close on Outside Click in Mobile View

Open bc-hvtk opened this issue 7 months ago • 2 comments

Hi,

First of all thank you for this extension, it's very handful. I'm facing an issue when the drawer's clip mode is DrawerClipMode.Never. Basically the only way to close it is to resize it. I'd the suggest to add something like:

 window.MudDrawerInterop = {
        initialize: function () {
            ...
            document.removeEventListener('click', this.handleOutsideClick);
            document.addEventListener('click', this.handleOutsideClick);
        },
...
       handleOutsideClick: function (event) {
            const mudDrawer = document.querySelector('.mud-drawer.mud-drawer--open');

            if (!mudDrawer) return;

            if (mudDrawer.contains(event.target) || event.target.closest('[data-mud-drawer-toggle]')) {
                return;
            }
            
            const drawerId = mudDrawer.id ? mudDrawer.id : '_no_id_provided_';
            MudDrawerInterop.toggleDrawer(drawerId);
        },

That should fix the issue with DrawerClipMode.Never. There is probably use cases we don't want this behaviour. What do you think?

Basic reproduction of the issue is quite simple. Just use ClipMode="DrawerClipMode.Never" on a MudDrawer with a mobile view the drawer goes over the burger button and you can't close it easily.

bc-hvtk avatar Mar 16 '25 10:03 bc-hvtk