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 c264843
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pat/contentbrowser/src/SelectedItems.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { flip } from "svelte/animate";
import { request } from "./api.js";
import { resolveIcon } from "./resolveIcon.js";
import Sortable from "sortablejs";
let ref;
let initializing = true;
Expand Down Expand Up @@ -36,6 +37,7 @@
onMount(async () => {
console.log(`${fieldId} start onMount()`);
await initializeSelectedItemsStore();
initializeSorting();
console.log(
`${fieldId} end onMount(). $selectedItems: ${JSON.stringify($selectedItems)}`,
);
Expand Down Expand Up @@ -79,9 +81,10 @@
const selectedItemsUids = await getSelectedItemsUids(initialValue);
$selectedItems = selectedItemsUids;
selectedUids.update(() => selectedItemsUids.map((x) => x.UID));
}
function initializeSorting() {
if ($config.maximumSelectionSize !== 1 && $selectedItems.length > 1) {
let Sortable = (await import("sortablejs")).default;
Sortable.create(
selectedItemsNode.previousSibling.querySelector(
".content-browser-selected-items",
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 c264843

Please sign in to comment.