mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 04:25:10 +00:00
perf(DndContext): ignore some context when UI is not designable
This commit is contained in:
parent
a7e086ccad
commit
e1e8f54d03
@ -77,6 +77,7 @@ const useDragEnd = (onDragEnd) => {
|
|||||||
export type DndContextProps = Props;
|
export type DndContextProps = Props;
|
||||||
|
|
||||||
export const DndContext = (props: Props) => {
|
export const DndContext = (props: Props) => {
|
||||||
|
const { designable } = useDesignable();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [visible, setVisible] = useState(true);
|
const [visible, setVisible] = useState(true);
|
||||||
|
|
||||||
@ -94,6 +95,10 @@ export const DndContext = (props: Props) => {
|
|||||||
|
|
||||||
const onDragEnd = useDragEnd(props?.onDragEnd);
|
const onDragEnd = useDragEnd(props?.onDragEnd);
|
||||||
|
|
||||||
|
if (!designable) {
|
||||||
|
return <>{props.children}</>;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DndKitContext collisionDetection={rectIntersection} {...props} onDragStart={onDragStart} onDragEnd={onDragEnd}>
|
<DndKitContext collisionDetection={rectIntersection} {...props} onDragStart={onDragStart} onDragEnd={onDragEnd}>
|
||||||
<DragOverlay
|
<DragOverlay
|
||||||
|
Loading…
Reference in New Issue
Block a user