simplesvelte 2.4.6 → 2.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Select.svelte +10 -11
- package/package.json +1 -1
package/dist/Select.svelte
CHANGED
|
@@ -295,30 +295,26 @@
|
|
|
295
295
|
function handleKeydown(e: KeyboardEvent) {
|
|
296
296
|
if (e.key === 'ArrowDown') {
|
|
297
297
|
e.preventDefault()
|
|
298
|
-
if (!dropdownOpen)
|
|
299
|
-
|
|
300
|
-
return
|
|
301
|
-
}
|
|
302
|
-
// Move to next option
|
|
298
|
+
if (!dropdownOpen) openDropdown()
|
|
299
|
+
// Move to next option (or first option if none highlighted)
|
|
303
300
|
const currentPos = optionIndices.indexOf(highlightedIndex)
|
|
304
301
|
const nextPos = currentPos + 1
|
|
305
302
|
if (nextPos < optionIndices.length) {
|
|
306
303
|
highlightedIndex = optionIndices[nextPos]
|
|
307
304
|
scrollToHighlighted(highlightedIndex)
|
|
308
305
|
}
|
|
306
|
+
searchEL?.focus()
|
|
309
307
|
} else if (e.key === 'ArrowUp') {
|
|
310
308
|
e.preventDefault()
|
|
311
|
-
if (!dropdownOpen)
|
|
312
|
-
|
|
313
|
-
return
|
|
314
|
-
}
|
|
315
|
-
// Move to previous option
|
|
309
|
+
if (!dropdownOpen) openDropdown()
|
|
310
|
+
// Move to previous option (or last option if none highlighted)
|
|
316
311
|
const currentPos = optionIndices.indexOf(highlightedIndex)
|
|
317
|
-
const prevPos = currentPos - 1
|
|
312
|
+
const prevPos = currentPos >= 0 ? currentPos - 1 : optionIndices.length - 1
|
|
318
313
|
if (prevPos >= 0) {
|
|
319
314
|
highlightedIndex = optionIndices[prevPos]
|
|
320
315
|
scrollToHighlighted(highlightedIndex)
|
|
321
316
|
}
|
|
317
|
+
searchEL?.focus()
|
|
322
318
|
} else if (e.key === 'Enter') {
|
|
323
319
|
e.preventDefault()
|
|
324
320
|
if (!dropdownOpen) {
|
|
@@ -334,6 +330,9 @@
|
|
|
334
330
|
}
|
|
335
331
|
} else if (e.key === 'Escape') {
|
|
336
332
|
closeDropdown()
|
|
333
|
+
} else if (e.key === 'Tab') {
|
|
334
|
+
// Close dropdown on tab to allow normal tab navigation
|
|
335
|
+
closeDropdown()
|
|
337
336
|
}
|
|
338
337
|
}
|
|
339
338
|
|