Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using the modal exclusively within an element other than the HTML body #32

Open
flekschas opened this issue Mar 28, 2021 · 3 comments
Labels
improvement Improved feature

Comments

@flekschas
Copy link
Owner

Currently, svelte-simple-modal assume that it's used globally. I.e., it overlays the body element. However, sometimes it can be useful to just use it within another (scrollable) container.

To support this we could traverse the DOM tree and find the first parent that is scrollable using for instance:

const isScrollable = (element) =>
  element.scrollHeight > element.clientHeight && window.getComputedStyle(element).overflowY.indexOf('hidden') === -1;

const getScrollableParent = (element) =>
  !element || element === document.body
    ? document.body
    : (isScrollable(element) ? element : getScrollableParent(element.parentNode));
@flekschas flekschas added the improvement Improved feature label Mar 28, 2021
@flekschas flekschas mentioned this issue Apr 11, 2022
@josdejong
Copy link

Is there a way to open a nested modal? Right now, when I open a second, nested modal from an modal, the parent modal disappears. Ideally, the second modal should be rendered on top of the original one, showing both.

@flekschas
Copy link
Owner Author

@josdejong there is not. This ticket is also more aimed at a way to bin the modal to a DOM element other than body rather then true nested in the sense that one modal is superimposing another modal.

@josdejong
Copy link

Ok I've created a separate issue: #89. Would be very useful, at least to me :)

@flekschas flekschas changed the title Allow nested the modal or using it a subcontainer Allow using the modal exclusively within an element other than the HTML body Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improved feature
Projects
None yet
Development

No branches or pull requests

2 participants