Skip to content

Commit

Permalink
fix initialize sorting when selecting items the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
petschki committed Apr 4, 2024
1 parent 197d73f commit 0780254
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/pat/contentbrowser/src/SelectedItems.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
onMount(async () => {
console.log(`${fieldId} start onMount()`);
await initializeSelectedItemsStore();
await initializeSorting();
console.log(
`${fieldId} end onMount(). $selectedItems: ${JSON.stringify($selectedItems)}`,
);
Expand Down Expand Up @@ -79,7 +80,9 @@
const selectedItemsUids = await getSelectedItemsUids(initialValue);
$selectedItems = selectedItemsUids;
selectedUids.update(() => selectedItemsUids.map((x) => x.UID));
}
async function initializeSorting() {
if ($config.maximumSelectionSize !== 1 && $selectedItems.length > 1) {
let Sortable = (await import("sortablejs")).default;
Sortable.create(
Expand Down Expand Up @@ -122,6 +125,7 @@
);
if ($selectedItems.length || !initializing) {
setNodeValue(selectedUidsFromSelectedItems());
initializeSorting();
event_dispatch("updateSelection", selectedUids);
}
}
Expand Down

0 comments on commit 0780254

Please sign in to comment.