From bffa7a02eb312c596b0a2dba09629b0862d7c58c Mon Sep 17 00:00:00 2001 From: Serge Pavlyuk Date: Thu, 5 Dec 2024 16:46:59 +0300 Subject: [PATCH] fix: add dnd context in dashkit with groups if there is no dnd wrapper presented (#225) * fix: add dnd context in dashkit with groups if there is no dnd wrepper presented * fix: rever Dashkit to PureComponent --- src/components/DashKit/DashKit.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/DashKit/DashKit.tsx b/src/components/DashKit/DashKit.tsx index af418f2..4818018 100644 --- a/src/components/DashKit/DashKit.tsx +++ b/src/components/DashKit/DashKit.tsx @@ -4,6 +4,7 @@ import noop from 'lodash/noop'; import pick from 'lodash/pick'; import {DEFAULT_GROUP, DEFAULT_NAMESPACE} from '../../constants'; +import {DashKitDnDContext} from '../../context/DashKitContext'; import type { Config, ConfigItem, @@ -27,6 +28,7 @@ import { SettingsProps, } from '../../typings'; import {RegisterManager, UpdateManager, reflowLayout} from '../../utils'; +import {DashKitDnDWrapper} from '../DashKitDnDWrapper/DashKitDnDWrapper'; import DashKitView from '../DashKitView/DashKitView'; import GridLayout from '../GridLayout/GridLayout'; import {OverlayControlItem, OverlayControlsCtxShape} from '../OverlayControls/OverlayControls'; @@ -114,6 +116,8 @@ export class DashKit extends React.PureComponent { focusable: false, }; + static contextType = DashKitDnDContext; + static registerPlugins(...plugins: Plugin[]) { plugins.forEach((plugin) => { registerManager.registerPlugin(plugin); @@ -204,7 +208,15 @@ export class DashKit extends React.PureComponent { metaRef = React.createRef(); render() { - return ; + const content = ( + + ); + + if (!this.context && this.props.groups) { + return {content}; + } + + return content; } getItemsMeta() {