diff --git a/.changeset/breezy-dingos-mate.md b/.changeset/breezy-dingos-mate.md new file mode 100644 index 000000000..3d7e02290 --- /dev/null +++ b/.changeset/breezy-dingos-mate.md @@ -0,0 +1,5 @@ +--- +'svelte-ux': patch +--- + +fix(SelectField): Properly handle option selection with option slot defined using `` or `
` diff --git a/packages/svelte-ux/src/lib/components/_SelectListOptions.svelte b/packages/svelte-ux/src/lib/components/_SelectListOptions.svelte index dc6451cfb..bf7180584 100644 --- a/packages/svelte-ux/src/lib/components/_SelectListOptions.svelte +++ b/packages/svelte-ux/src/lib/components/_SelectListOptions.svelte @@ -44,8 +44,8 @@ if (e.target instanceof HTMLElement) { // Find slot parent of click target option, fallback to `e.target` if slot is not overridden - // Use `.options > ` in case slot is nested (ex. GraphQLSelect with slot) - const slotEl = e.target.closest('.options > [slot=option]') ?? e.target; + // Use `.options > *` in case slot is nested (ex. `` vs `
`) + const slotEl = e.target.closest('.options > *') ?? e.target; // Find the index of the clicked on element (ignoring group headers) const optionIndex = slotEl ? [...menuOptionsEl.children]