From 2dc1fc21e11f549ccf3fcfa4b628a82583a1ed4c Mon Sep 17 00:00:00 2001 From: GermanVor Date: Fri, 9 Feb 2024 09:15:54 +0100 Subject: [PATCH] chore: replace T generic --- src/components/TreeSelect/DndTreeSelect.tsx | 89 +++++++++++---------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/src/components/TreeSelect/DndTreeSelect.tsx b/src/components/TreeSelect/DndTreeSelect.tsx index 87233d60c0..71e375b682 100644 --- a/src/components/TreeSelect/DndTreeSelect.tsx +++ b/src/components/TreeSelect/DndTreeSelect.tsx @@ -47,7 +47,7 @@ export function DndTreeSelect({ () => initialDroppableId || `default-droppable-id-${dndTreeSelectCount++}`, ); - const renderContainer = React.useCallback>( + const renderContainer = React.useCallback>( ({renderItem, visibleFlattenIds, items: _items, containerRef, id}) => { const handleDrugEnd: OnDragEndResponder = ({destination, source}) => { if (destination?.index !== undefined && destination?.index !== source.index) { @@ -86,48 +86,51 @@ export function DndTreeSelect({ [items, setItems, propsRenderContainer, droppableId], ); - const renderDndItem = React.useCallback>((item, state, _, idx) => { - const endSlot = - item.endSlot ?? (item.isDragDisabled ? undefined : ); - - const commonProps = { - ...state, - ...item, - endSlot, - }; - - return ( - - {(provided, snapshot) => { - const style: React.CSSProperties = { - ...provided.draggableProps.style, - }; - - // not expected offset appears, one way to fix - remove this offsets explicitly - if (snapshot.isDragging) { - style.left = undefined; - style.top = undefined; - } - - return ( - - ); - }} - - ); - }, []); + const renderDndItem = React.useCallback>( + (item, state, _, idx) => { + const endSlot = + item.endSlot ?? (item.isDragDisabled ? undefined : ); + + const commonProps = { + ...state, + ...item, + endSlot, + }; + + return ( + + {(provided, snapshot) => { + const style: React.CSSProperties = { + ...provided.draggableProps.style, + }; + + // not expected offset appears, one way to fix - remove this offsets explicitly + if (snapshot.isDragging) { + style.left = undefined; + style.top = undefined; + } + + return ( + + ); + }} + + ); + }, + [], + ); return (