-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: can't properly drag and drop in empty record group (#9039)
Fix #8968 Fix issue with drag and drop when record group are empty. Happy to discuss the implementation, as it's limited to the `@hello-pangea/dnd` api. --------- Co-authored-by: Charles Bochet <[email protected]>
- Loading branch information
1 parent
d56c815
commit 07aaf08
Showing
29 changed files
with
348 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,6 @@ | ||
import React, { Ref, RefCallback } from 'react'; | ||
import { isFunction } from '@sniptt/guards'; | ||
import { Ref, RefCallback } from 'react'; | ||
import { combineRefs } from '~/utils/combineRefs'; | ||
|
||
export const useCombinedRefs = | ||
<T>(...refs: (Ref<T> | undefined)[]): RefCallback<T> => | ||
(node: T) => { | ||
for (const ref of refs) { | ||
if (isFunction(ref)) { | ||
ref(node); | ||
} else if (ref !== null && ref !== undefined) { | ||
(ref as React.MutableRefObject<T | null>).current = node; | ||
} | ||
} | ||
}; | ||
export const useCombinedRefs = <T>( | ||
...refs: (Ref<T> | undefined)[] | ||
): RefCallback<T> => combineRefs<T>(...refs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 5 additions & 10 deletions
15
...ges/twenty-front/src/modules/object-record/record-table/contexts/RecordTableRowContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
import { DraggableProvidedDragHandleProps } from '@hello-pangea/dnd'; | ||
import { createContext } from 'react'; | ||
import { createRequiredContext } from '~/utils/createRequiredContext'; | ||
|
||
export type RecordTableRowContextProps = { | ||
export type RecordTableRowContextValue = { | ||
pathToShowPage: string; | ||
objectNameSingular: string; | ||
recordId: string; | ||
rowIndex: number; | ||
isSelected: boolean; | ||
inView: boolean; | ||
isPendingRow?: boolean; | ||
isDragging: boolean; | ||
dragHandleProps: DraggableProvidedDragHandleProps | null; | ||
inView?: boolean; | ||
isDragDisabled?: boolean; | ||
}; | ||
|
||
export const RecordTableRowContext = createContext<RecordTableRowContextProps>( | ||
{} as RecordTableRowContextProps, | ||
); | ||
export const [RecordTableRowContextProvider, useRecordTableRowContextOrThrow] = | ||
createRequiredContext<RecordTableRowContextValue>('RecordTableRowContext'); |
14 changes: 14 additions & 0 deletions
14
...y-front/src/modules/object-record/record-table/contexts/RecordTableRowDraggableContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { DraggableProvidedDragHandleProps } from '@hello-pangea/dnd'; | ||
import { createRequiredContext } from '~/utils/createRequiredContext'; | ||
|
||
export type RecordTableRowDraggableContextValue = { | ||
isDragging: boolean; | ||
dragHandleProps: DraggableProvidedDragHandleProps | null; | ||
}; | ||
|
||
export const [ | ||
RecordTableRowDraggableContextProvider, | ||
useRecordTableRowDraggableContextOrThrow, | ||
] = createRequiredContext<RecordTableRowDraggableContextValue>( | ||
'RecordTableRowDraggableContext', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
...ules/object-record/record-table/record-table-cell/components/RecordTableLastEmptyCell.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
...ty-front/src/modules/object-record/record-table/record-table-cell/hooks/__mocks__/cell.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.