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
commit ed1636e3bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 120 additions and 2 deletions

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