Skip to content

Commit

Permalink
feat: pass gridLayout setting for each group
Browse files Browse the repository at this point in the history
  • Loading branch information
flops committed Nov 19, 2024
1 parent af61e22 commit e4d190e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/components/GridItem/GridItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const windowFocusObserver = new WindowFocusObserver();
class GridItem extends React.PureComponent {
static propTypes = {
adjustWidgetLayout: PropTypes.func.isRequired,
gridLayout: PropTypes.object,
id: PropTypes.string,
item: PropTypes.object,
isDragging: PropTypes.bool,
Expand Down Expand Up @@ -222,6 +223,7 @@ class GridItem extends React.PureComponent {
forwardedPluginRef={this.props.forwardedPluginRef}
onItemMountChange={this.props.onItemMountChange}
onItemRender={this.props.onItemRender}
gridLayout={this.props.gridLayout}
/>
</div>
{!noOverlay && this.renderOverlay()}
Expand Down
6 changes: 4 additions & 2 deletions src/components/GridLayout/GridLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ export default class GridLayout extends React.PureComponent {
return false;
};

renderTemporaryPlaceholder() {
renderTemporaryPlaceholder(gridLayout) {
const {temporaryLayout, noOverlay, draggableHandleClassName} = this.context;

if (!temporaryLayout || !temporaryLayout.dragProps) {
Expand All @@ -572,6 +572,7 @@ export default class GridLayout extends React.PureComponent {
isPlaceholder={true}
noOverlay={noOverlay}
withCustomHandle={Boolean(draggableHandleClassName)}
gridLayout={gridLayout}
/>
);
}
Expand Down Expand Up @@ -662,10 +663,11 @@ export default class GridLayout extends React.PureComponent {
withCustomHandle={Boolean(draggableHandleClassName)}
onItemMountChange={onItemMountChange}
onItemRender={onItemRender}
gridLayout={properties}
/>
);
})}
{this.renderTemporaryPlaceholder()}
{this.renderTemporaryPlaceholder(properties)}
</Layout>
);
}
Expand Down
6 changes: 4 additions & 2 deletions src/hocs/prepareItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {DashKitContext} from '../context/DashKitContext';
export function prepareItem(Component) {
return class PrepareItem extends React.Component {
static propTypes = {
gridLayout: PropTypes.object,
adjustWidgetLayout: PropTypes.func.isRequired,
layout: PropTypes.array,
id: PropTypes.string,
Expand Down Expand Up @@ -45,7 +46,8 @@ export function prepareItem(Component) {

_currentRenderProps = {};
getRenderProps = () => {
const {id, width, height, item, adjustWidgetLayout, layout, isPlaceholder} = this.props;
const {id, width, height, item, adjustWidgetLayout, layout, isPlaceholder, gridLayout} =
this.props;
const {itemsState, itemsParams, registerManager, settings, context, editMode} =
this.context;
const {data, defaults, namespace} = item;
Expand All @@ -64,7 +66,7 @@ export function prepareItem(Component) {
settings,
context,
layout,
gridLayout: registerManager.gridLayout,
gridLayout: gridLayout || registerManager.gridLayout,
adjustWidgetLayout,
isPlaceholder,
};
Expand Down

0 comments on commit e4d190e

Please sign in to comment.