Skip to content

Commit

Permalink
fix: add dnd context in dashkit with groups if there is no dnd wrappe…
Browse files Browse the repository at this point in the history
…r presented (#225)

* fix: add dnd context in dashkit with groups if there is no dnd wrepper presented

* fix: rever Dashkit to PureComponent
  • Loading branch information
flops authored Dec 5, 2024
1 parent 13676f8 commit bffa7a0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/DashKit/DashKit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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';
Expand Down Expand Up @@ -114,6 +116,8 @@ export class DashKit extends React.PureComponent<DashKitInnerProps> {
focusable: false,
};

static contextType = DashKitDnDContext;

static registerPlugins(...plugins: Plugin[]) {
plugins.forEach((plugin) => {
registerManager.registerPlugin(plugin);
Expand Down Expand Up @@ -204,7 +208,15 @@ export class DashKit extends React.PureComponent<DashKitInnerProps> {
metaRef = React.createRef<GridLayout>();

render() {
return <DashKitView registerManager={registerManager} ref={this.metaRef} {...this.props} />;
const content = (
<DashKitView registerManager={registerManager} ref={this.metaRef} {...this.props} />
);

if (!this.context && this.props.groups) {
return <DashKitDnDWrapper>{content}</DashKitDnDWrapper>;
}

return content;
}

getItemsMeta() {
Expand Down

0 comments on commit bffa7a0

Please sign in to comment.