vikramlearning / blazorbootstrap

An Enterprise-class Blazor Bootstrap Component library built on the Blazor and Bootstrap CSS frameworks.
https://docs.blazorbootstrap.com/
Apache License 2.0
769 stars 40 forks source link

Nested dynamic modals onhide problems. #786

Open christiancvi opened 4 months ago

christiancvi commented 4 months ago

Steps to reproduce the behavior:

  1. Create dynamic fullscreen modal with Modal ref and showasync...
  2. Inside this, create other dynamic fullscreen modal with Modal ref.... and showasync
  3. Inside last, create dynamic modal (size large but not fullscreen) with same method modal ref... showasync
  4. When close last modal, the scroll show body scroll, not to the last modal scroll.

Expected behavior: I think what should happen is that when closing the last dialog, the nesting modals should be preserved correctly, and the body scroll should not appear.

christiancvi commented 4 months ago

Solved adding this script:

document.addEventListener('hidden.bs.modal', function (event) {            
            if (event.target.classList.contains('modal')) {
                var modals = document.querySelectorAll('.modal.show');

                if (modals.length > 0) {
                    document.body.style.overflow = 'hidden';
                    document.body.style.paddingRight = '0px';
                }
            }
        });