fix(tui): clamp dialog selection after options shrink (#36712)

This commit is contained in:
Kit Langton
2026-07-13 15:59:04 -04:00
committed by GitHub
parent 90a87b2a0c
commit ed1636e3bd
2 changed files with 120 additions and 2 deletions
+5 -1
View File
@@ -233,7 +233,11 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
on(
() => props.options,
() => {
if (!props.preserveSelection) return
if (!props.preserveSelection) {
const next = Math.min(store.selected, flat().length - 1)
if (next >= 0 && next !== store.selected) setStore("selected", next)
return
}
if (resetSelection && store.filter.length > 0) {
const option = flat()[0]
if (!option) return