mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
fix(core): redudant drop target register (#9177)
fix the following issue. root cause is that options.element is being reused when cleaning up, but if its value comes from a ref, it might be null at that point. 
This commit is contained in:
@@ -231,9 +231,13 @@ export const useDropTarget = <D extends DNDData = DNDData>(
|
||||
|
||||
const dropTargetOptions = useMemo(() => {
|
||||
const wrappedCanDrop = dropTargetGet(options.canDrop, options);
|
||||
let _element: HTMLElement | null = null;
|
||||
return {
|
||||
get element() {
|
||||
return dropTargetRef.current;
|
||||
if (!_element) {
|
||||
_element = dropTargetRef.current;
|
||||
}
|
||||
return _element;
|
||||
},
|
||||
canDrop: wrappedCanDrop
|
||||
? (args: DropTargetGetFeedback<D>) => {
|
||||
|
||||
Reference in New Issue
Block a user