From 15e0b6b95d433b646a74a5be74f59f2314b145ee Mon Sep 17 00:00:00 2001 From: Serge Pavlyuk Date: Thu, 5 Dec 2024 15:35:23 +0300 Subject: [PATCH] fix: add dnd context in dashkit with groups if there is no dnd wrepper presented --- src/components/DashKit/DashKit.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/DashKit/DashKit.tsx b/src/components/DashKit/DashKit.tsx index af418f2..8a4e22d 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'; @@ -97,7 +99,7 @@ const getReflowGroupsConfig = (groups: DashKitGroup[] = []) => { }; }; -export class DashKit extends React.PureComponent { +export class DashKit extends React.Component { static defaultProps: DashKitDefaultProps = { onItemEdit: noop, onChange: noop, @@ -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() {