mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
fix missing autoscroll cleanup on ScrollArea
This commit is contained in:
@@ -48,6 +48,8 @@ export const ScrollArea = forwardRef((props: ScrollAreaProps, ref: Ref<HTMLDivEl
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { current: root } = containerRef;
|
const { current: root } = containerRef;
|
||||||
|
|
||||||
|
let autoScrollCleanup: (() => void) | null = null;
|
||||||
|
|
||||||
if (scroller && root) {
|
if (scroller && root) {
|
||||||
initialize({
|
initialize({
|
||||||
elements: { viewport: scroller as HTMLElement },
|
elements: { viewport: scroller as HTMLElement },
|
||||||
@@ -55,7 +57,7 @@ export const ScrollArea = forwardRef((props: ScrollAreaProps, ref: Ref<HTMLDivEl
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (allowDragScroll) {
|
if (allowDragScroll) {
|
||||||
autoScrollForElements({
|
autoScrollCleanup = autoScrollForElements({
|
||||||
canScroll: (args) => {
|
canScroll: (args) => {
|
||||||
const data = args.source.data as unknown as DragData<unknown>;
|
const data = args.source.data as unknown as DragData<unknown>;
|
||||||
if (data.type === DragTarget.TABLE_COLUMN) return false;
|
if (data.type === DragTarget.TABLE_COLUMN) return false;
|
||||||
@@ -68,7 +70,13 @@ export const ScrollArea = forwardRef((props: ScrollAreaProps, ref: Ref<HTMLDivEl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => osInstance()?.destroy();
|
return () => {
|
||||||
|
if (autoScrollCleanup) {
|
||||||
|
autoScrollCleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
osInstance()?.destroy();
|
||||||
|
};
|
||||||
}, [allowDragScroll, initialize, osInstance, scroller]);
|
}, [allowDragScroll, initialize, osInstance, scroller]);
|
||||||
|
|
||||||
const mergedRef = useMergedRef(ref, containerRef);
|
const mergedRef = useMergedRef(ref, containerRef);
|
||||||
|
|||||||
Reference in New Issue
Block a user