Fix DropdownInput widget not reactively updating when its content changes (#2770)

* Improve reactivity of DropdownInput.svelte

* Fix formatting lint

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
James Lindsay
2025-06-28 02:59:03 +00:00
committed by GitHub
co-authored by Keavon Chambers
parent 62c7f88f5b
commit 532e913017
2 changed files with 17 additions and 2 deletions
@@ -30,6 +30,7 @@
let open = false;
$: watchSelectedIndex(selectedIndex);
$: watchEntries(entries);
$: watchActiveEntry(activeEntry);
$: watchOpen(open);
@@ -38,7 +39,13 @@
}
// Called only when `selectedIndex` is changed from outside this component
function watchSelectedIndex(_?: number) {
function watchSelectedIndex(_?: typeof selectedIndex) {
activeEntrySkipWatcher = true;
activeEntry = makeActiveEntry();
}
// Called only when `entries` is changed from outside this component
function watchEntries(_?: typeof entries) {
activeEntrySkipWatcher = true;
activeEntry = makeActiveEntry();
}