Skip to content

Added ability to render the select list into another element using svelte-portal #699

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@
}
},
"dependencies": {
"svelte-floating-ui": "1.5.8"
"svelte-floating-ui": "1.5.8",
"svelte-portal": "^2.2.1"
}
}
5 changes: 4 additions & 1 deletion src/lib/Select.svelte
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
import { beforeUpdate, createEventDispatcher, onDestroy, onMount } from 'svelte';
import { offset, flip, shift } from 'svelte-floating-ui/dom';
import { createFloatingActions } from 'svelte-floating-ui';
import { portal } from "svelte-portal";

const dispatch = createEventDispatcher();

@@ -43,6 +44,7 @@
export let required = false;
export let closeListOnChange = true;
export let clearFilterTextOnBlur = true;
export let renderListTo = undefined;

export let createGroupHeaderItem = (groupValue, item) => {
return {
@@ -683,8 +685,9 @@
bind:this={container}
use:floatingRef
role="none">
{#if listOpen}
{#if listOpen && container}
<div
use:portal={renderListTo ?? container}
use:floatingContent
bind:this={list}
class="svelte-select-list"