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 <charles@twenty.com>
This commit is contained in:
15
packages/twenty-front/src/utils/combineRefs.ts
Normal file
15
packages/twenty-front/src/utils/combineRefs.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { isFunction } from '@sniptt/guards';
|
||||
import { MutableRefObject, Ref } from 'react';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const combineRefs = <T>(...refs: (Ref<T> | undefined)[]) => {
|
||||
return (node: T) => {
|
||||
for (const ref of refs) {
|
||||
if (isFunction(ref)) {
|
||||
ref(node);
|
||||
} else if (isDefined(ref) && 'current' in ref) {
|
||||
(ref as MutableRefObject<T | null>).current = node;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user