ui icon indicating copy to clipboard operation
ui copied to clipboard

shadcn AlertDialog doesn't allow window scrolling

Open artistoflight opened this issue 1 year ago • 4 comments

Screenshot (301)

Screenshot (302)

shadcn AlertDialog doesn't allow window scrolling right side when click AlertDialogTrigger

artistoflight avatar Jan 20 '24 15:01 artistoflight

@SOU-code it's not the issue with shadcn-ui but of radix-ui library

imopbuilder avatar Jan 21 '24 05:01 imopbuilder

@SOU-code it's not the issue with shadcn-ui but of radix-ui library

but it's happened

artistoflight avatar Jan 28 '24 06:01 artistoflight

@SOU-code

You want the background documents to scroll, right??

imopbuilder avatar Jan 28 '24 08:01 imopbuilder

@SOU-code

You can fix it by adding the styles to the body

.body {
	overflow-y: scroll !important;
}

make sure you add a className of body to the body element

<body className={`${inter.className} body`}>{children}</body>

https://github.com/shadcn-ui/ui/assets/150527559/4a731eaf-1bfc-4451-9829-05679dd197d9

imopbuilder avatar Jan 28 '24 09:01 imopbuilder

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

shadcn avatar Feb 19 '24 23:02 shadcn

With this script you can prevent added attribute 'data-scroll-locked' in the body and you will prevent the blocked scroll body

<script>
        function removeScrollLockedAttribute(mutationsList) {
            for (let mutation of mutationsList) {
                if (mutation.type === 'attributes' && mutation.attributeName === 'data-scroll-locked') {
                    document.body.removeAttribute('data-scroll-locked');
                }
            }
        }

        const observer = new MutationObserver(removeScrollLockedAttribute);

        observer.observe(document.body, { attributes: true });

        const preventScrollLock = new Proxy(document.body, {
            set: function(target, key, value) {
                if (key === 'setAttribute' && value[0] === 'data-scroll-locked') {
                    return false; // Prevenir que se añada el atributo
                }
                return Reflect.set(target, key, value);
            }
        });

        document.body.setAttribute = preventScrollLock.setAttribute;
    </script>

BradMoyetones avatar Aug 10 '24 02:08 BradMoyetones