Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pass gridLayout setting for each group #220

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading