Skip to content

Portal / render the multiselect outside of the current DOM structure #301

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

Closed
MarcDAFrame opened this issue Mar 5, 2025 · 2 comments · Fixed by #306
Closed

Portal / render the multiselect outside of the current DOM structure #301

MarcDAFrame opened this issue Mar 5, 2025 · 2 comments · Fixed by #306

Comments

@MarcDAFrame
Copy link

This is a pretty common issue w/ dropdowns is how they interact with Modals.

Image

Ideally the dropdown overflows outside of the modal instead of causing it to expand / scroll.

This is often fixed with portals.

Wondering what your thoughts on fixing this are.

Cheers,
Marc

@janosh
Copy link
Owner

janosh commented Mar 6, 2025

sounds good, happy to take a PR for that 👍

@MarcDAFrame
Copy link
Author

Hey Janosh - I got a PR in for a new fixed prop

Hope it helps : )

janosh added a commit that referenced this issue May 17, 2025
to extend dropdown outside of parent component (e.g. inside a modal dialog)

- new `portal` function manages dropdown rendering if portal prop is not empty
- `MultiSelectProps` include optional `portal` parameter to enable and customize portal functionality
- refactored the `add` function to simplify max selection logic
- improved CSS for dropdown positioning and z-index management when using the portal
janosh added a commit that referenced this issue May 17, 2025
* fix drag and drop selected options and reinstate playwright test

also reinstate multiselect test 'opens dropdown on focus', no longer fails

* more CmdPalette coverage with vitest in tests/unit/CmdPalette.svelte.test.ts

* simplify CSS scoping

* add/remove use generic T for option arg type, rename arg for clarity

* minor refactor CmdPalette

* fix escape key navigating back to landing page from demo pages

* add portal functionality to MultiSelect component (closes #301)

to extend dropdown outside of parent component (e.g. inside a modal dialog)

- new `portal` function manages dropdown rendering if portal prop is not empty
- `MultiSelectProps` include optional `portal` parameter to enable and customize portal functionality
- refactored the `add` function to simplify max selection logic
- improved CSS for dropdown positioning and z-index management when using the portal

* add /modal/+page.svelte demo page for portal feature

* playwright test for MultiSelect portal feature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants