Skip to content

Commit 8005410

Browse files
committed
pnpm remove @testing-library/jest-dom @testing-library/svelte @testing-library/user-event, reverting MultiSelect.svelte.test.ts to pure vitest
1 parent 5b00d9c commit 8005410

File tree

3 files changed

+147
-125
lines changed

3 files changed

+147
-125
lines changed

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
"@sveltejs/kit": "^2.21.0",
3434
"@sveltejs/package": "2.3.11",
3535
"@sveltejs/vite-plugin-svelte": "^5.0.3",
36-
"@testing-library/jest-dom": "^6.6.3",
37-
"@testing-library/svelte": "^5.2.7",
38-
"@testing-library/user-event": "^14.6.1",
3936
"@types/node": "^22.15.18",
4037
"@vitest/coverage-v8": "^3.1.3",
4138
"eslint": "^9.26.0",

src/lib/MultiSelect.svelte

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
}
183183
184184
let option_msg_is_active = $state(false) // controls active state of <li>{createOptionMsg}</li>
185-
let window_width = $state<number>()
185+
let window_width = $state(0)
186186
187187
// options matching the current search text
188188
$effect.pre(() => {
@@ -206,6 +206,7 @@
206206
207207
// add an option to selected list
208208
function add(option: Option, event: Event) {
209+
event.stopPropagation()
209210
if (maxSelect && maxSelect > 1 && selected.length >= maxSelect) wiggle = true
210211
if (!isNaN(Number(option)) && typeof selected.map(get_label)[0] === `number`) {
211212
option = Number(option) as Option // convert to number if possible
@@ -348,7 +349,7 @@
348349
event.preventDefault() // prevent enter key from triggering form submission
349350
350351
if (activeOption) {
351-
if (selected.includes(activeOption)) remove(activeOption)
352+
if (selected.includes(activeOption)) remove(activeOption, event)
352353
else add(activeOption, event)
353354
searchText = ``
354355
} else if (allowUserOptions && searchText.length > 0) {
@@ -398,7 +399,7 @@
398399
else if (event.key === `Backspace` && selected.length > 0 && !searchText) {
399400
event.stopPropagation()
400401
// Don't prevent default, allow normal backspace behavior if not removing
401-
remove(selected.at(-1) as Option)
402+
remove(selected.at(-1) as Option, event)
402403
}
403404
// make first matching option active on any keypress (if none of the above special cases match)
404405
else if (matchingOptions.length > 0 && activeIndex === null) {
@@ -580,7 +581,7 @@
580581
{/if}
581582
{#if !disabled && (minSelect === null || selected.length > minSelect)}
582583
<button
583-
onmouseup={(event) => remove(option, event)}
584+
onclick={(event) => remove(option, event)}
584585
onkeydown={if_enter_or_space((event) => remove(option, event))}
585586
type="button"
586587
title="{removeBtnTitle} {get_label(option)}"
@@ -660,7 +661,7 @@
660661
type="button"
661662
class="remove remove-all"
662663
title={removeAllTitle}
663-
onmouseup={remove_all}
664+
onclick={remove_all}
664665
onkeydown={if_enter_or_space(remove_all)}
665666
>
666667
{#if removeIcon}

0 commit comments

Comments
 (0)