Skip to content

Commit

Permalink
feat: remove preventDoubleCompact flag (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
goshander authored Jan 31, 2023
1 parent 30e415e commit 9b95e61
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/components/DashKit/DashKit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ interface DashKitDefaultProps {
overlayControls?: Record<string, OverlayControlItem[]>;
noOverlay?: boolean;
draggableHandleClassName?: string;
_EXPERIMENTAL_preventDoubleCompact?: boolean;
}

export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaultProps> {}
Expand Down
5 changes: 0 additions & 5 deletions src/components/DashKit/__stories__/DashKitShowcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type DashKitDemoState = {
lastAction: string;
customControlsActionData: number;
showCustomMenu: boolean;
_EXPERIMENTAL_preventDoubleCompact: boolean;
};

export class DashKitShowcase extends React.Component<{}, DashKitDemoState> {
Expand All @@ -39,7 +38,6 @@ export class DashKitShowcase extends React.Component<{}, DashKitDemoState> {
lastAction: 'Нет',
customControlsActionData: 0,
showCustomMenu: true,
_EXPERIMENTAL_preventDoubleCompact: false,
};

private dashKitRef = React.createRef<DashKit>();
Expand Down Expand Up @@ -133,9 +131,6 @@ export class DashKitShowcase extends React.Component<{}, DashKitDemoState> {
settings={this.state.settings}
ref={this.dashKitRef}
overlayControls={controls}
_EXPERIMENTAL_preventDoubleCompact={
this.state._EXPERIMENTAL_preventDoubleCompact
}
/>
</Demo.Row>
</Demo>
Expand Down
20 changes: 2 additions & 18 deletions src/hocs/withContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import {DashKitContext} from '../context/DashKitContext';
import {UpdateManager} from '../utils';
import {getItemsParams, getItemsState} from '../shared';
import isEqual from 'lodash/isEqual';
import {utils as gridLayoutUtils} from 'react-grid-layout';

const LAYOUT_COMPACTING_TYPE = 'vertical';

function useMemoStateContext(props) {
// так как мы не хотим хранить параметры виджета с активированной автовысотой в сторе и на сервере, актуальный
Expand Down Expand Up @@ -53,29 +50,16 @@ function useMemoStateContext(props) {
}
});

// [experimental] if the _prevent Double Compact is enabled, then skip recalculate layout with auto height
// после того, как у виждета активировали автовысоту и его параметр "h" изменился, это приведёт, также, и к
// изменению параметра (координаты) "y" у элементов расположенных под ним, поэтому, после того, как
// значения параметра "h" виджетов с активированной автовысотой были изменены, необходимо изменить и
// координату "y" виджетов расположенных ниже
const compactedLayout = props._EXPERIMENTAL_preventDoubleCompact
? currentInnerLayout
: gridLayoutUtils.compact(
currentInnerLayout,
LAYOUT_COMPACTING_TYPE,
props.registerManager.gridLayout.cols,
);

const newConfig = UpdateManager.updateLayout({
layout: compactedLayout,
layout: currentInnerLayout,
config: props.config,
});

if (!isEqual(newConfig.layout, props.config.layout)) {
onChange({config: newConfig});
}
},
[props._EXPERIMENTAL_preventDoubleCompact, props.registerManager, props.config, onChange],
[props.config, onChange],
);

const onItemRemove = React.useCallback(
Expand Down

0 comments on commit 9b95e61

Please sign in to comment.