From f2dc8e32c37e752263b0dac3cee486e5189f8f9c Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Thu, 31 Aug 2023 09:26:04 +0200 Subject: [PATCH] Make small adjustements --- src/components/DraggableList/index.tsx | 4 ++-- src/components/DraggableList/types.tsx | 2 +- src/components/DraggableList/useDraggableInPortal.tsx | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/DraggableList/index.tsx b/src/components/DraggableList/index.tsx index 4752dd949dcc..210fbc7cec1a 100644 --- a/src/components/DraggableList/index.tsx +++ b/src/components/DraggableList/index.tsx @@ -4,14 +4,14 @@ import {ScrollView} from 'react-native'; import useDraggableInPortal from './useDraggableInPortal'; import type {DraggableListProps, DefaultItemProps} from './types'; -type ReoderParams = { +type ReorderParams = { list: T[]; startIndex: number; endIndex: number; }; // Function to help us with reordering the result -const reorder = ({list, startIndex, endIndex}: ReoderParams): T[] => { +const reorder = ({list, startIndex, endIndex}: ReorderParams): T[] => { const result = Array.from(list); const [removed] = result.splice(startIndex, 1); diff --git a/src/components/DraggableList/types.tsx b/src/components/DraggableList/types.tsx index 10a2d713ef34..2aa3e6333f11 100644 --- a/src/components/DraggableList/types.tsx +++ b/src/components/DraggableList/types.tsx @@ -11,7 +11,7 @@ type DraggableListProps = { renderItem: (params: RenderItemParams) => React.ReactNode; onDragEnd?: (params: {data: T[]}) => void; onDragBegin?: () => void; - onPlaceholderIndexChange?: ((placeholderIndex: number) => void); + onPlaceholderIndexChange?: (placeholderIndex: number) => void; renderClone?: DraggableChildrenFn; shouldUsePortal?: boolean; onContentSizeChange?: ((w: number, h: number) => void) | undefined; diff --git a/src/components/DraggableList/useDraggableInPortal.tsx b/src/components/DraggableList/useDraggableInPortal.tsx index 586bab459eb5..3afaa8f6b626 100644 --- a/src/components/DraggableList/useDraggableInPortal.tsx +++ b/src/components/DraggableList/useDraggableInPortal.tsx @@ -1,4 +1,4 @@ -import type {DraggableChildrenFn, DraggingStyle} from 'react-beautiful-dnd'; +import type {DraggableChildrenFn} from 'react-beautiful-dnd'; import {useEffect, useRef} from 'react'; import {createPortal} from 'react-dom'; @@ -32,8 +32,8 @@ export default function useDraggableInPortal({shouldUsePortal}: DraggableInPorta return (render) => (provided, snapshot, rubric) => { const result = render(provided, snapshot, rubric); - const style = provided.draggableProps.style as DraggingStyle; - if (style.position === 'fixed') { + const style = provided.draggableProps.style; + if (style && 'position' in style && style.position === 'fixed') { return createPortal(result, element); } return result;