Skip to content

Commit

Permalink
fix(list, sortable-list, value-list): Emit calciteListOrderChange whe…
Browse files Browse the repository at this point in the history
…n dragging between lists. #7046
  • Loading branch information
driskull committed Aug 29, 2023
1 parent d246be0 commit f793cc4
Showing 1 changed file with 16 additions and 28 deletions.
44 changes: 16 additions & 28 deletions packages/calcite-components/src/utils/sortableComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ export interface SortableComponent {
onDragSort: (event: Sortable.SortableEvent) => void;

/**
* Element dragging started.
* Called when any sortable component drag starts.
*/
onDragStart?: () => void;
onDragStart: () => void;

/**
* Element dragging ended.
* Called when any sortable component drag ends.
*/
onDragEnd?: () => void;
onDragEnd: () => void;
}

/**
Expand Down Expand Up @@ -101,10 +101,10 @@ export function connectSortableComponent(component: SortableComponent): void {
}),
handle,
onStart: () => {
onSortingStart();
onDragStart();
},
onEnd: () => {
onSortingEnd();
onDragEnd();
},
onSort: (event) => {
component.onDragSort(event);
Expand All @@ -124,28 +124,16 @@ export function disconnectSortableComponent(component: SortableComponent): void
component.sortable = null;
}

function dragStarted(component: SortableComponent): void {
component.dragging = true;
component.onDragStart();
}

/**
* Helper to handle nested SortableComponents on `Sortable.onStart`.
*
*/
function onSortingStart(): void {
Array.from(sortableComponentSet).forEach((component) => dragStarted(component));
}

function dragEnded(component: SortableComponent): void {
component.dragging = false;
component.onDragEnd();
function onDragStart(): void {
Array.from(sortableComponentSet).forEach((component) => {
component.dragging = true;
component.onDragStart();
});
}

/**
* Helper to handle nested SortableComponents on `Sortable.onEnd`.
*
*/
function onSortingEnd(): void {
Array.from(sortableComponentSet).forEach((component) => dragEnded(component));
function onDragEnd(): void {
Array.from(sortableComponentSet).forEach((component) => {
component.dragging = false;
component.onDragEnd();
});
}

0 comments on commit f793cc4

Please sign in to comment.