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; let open = false;
$: watchSelectedIndex(selectedIndex); $: watchSelectedIndex(selectedIndex);
$: watchEntries(entries);
$: watchActiveEntry(activeEntry); $: watchActiveEntry(activeEntry);
$: watchOpen(open); $: watchOpen(open);
@@ -38,7 +39,13 @@
} }
// Called only when `selectedIndex` is changed from outside this component // 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; activeEntrySkipWatcher = true;
activeEntry = makeActiveEntry(); activeEntry = makeActiveEntry();
} }
+9 -1
View File
@@ -291,7 +291,15 @@ pub fn migrate_image_frame<'de, D: serde::Deserializer<'de>>(deserializer: D) ->
*image_frame_table.instance_mut_iter().next().unwrap().alpha_blending = alpha_blending; *image_frame_table.instance_mut_iter().next().unwrap().alpha_blending = alpha_blending;
image_frame_table image_frame_table
} }
FormatVersions::ImageFrame(image_frame) => RasterDataTable::new(Raster::new_cpu(image_frame.instance_ref_iter().next().unwrap().instance.image.clone())), FormatVersions::ImageFrame(image_frame) => RasterDataTable::new(Raster::new_cpu(
image_frame
.instance_ref_iter()
.next()
.unwrap_or(Instances::new(ImageFrame::default()).instance_ref_iter().next().unwrap())
.instance
.image
.clone(),
)),
FormatVersions::ImageFrameTable(image_frame_table) => RasterDataTable::new(Raster::new_cpu(image_frame_table.instance_ref_iter().next().unwrap().instance.clone())), FormatVersions::ImageFrameTable(image_frame_table) => RasterDataTable::new(Raster::new_cpu(image_frame_table.instance_ref_iter().next().unwrap().instance.clone())),
FormatVersions::RasterDataTable(raster_data_table) => raster_data_table, FormatVersions::RasterDataTable(raster_data_table) => raster_data_table,
}) })