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

IBX-1684: Added adapt context menu when content tree is resized #113

Merged
merged 1 commit into from
Dec 15, 2021
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,28 @@ export default class ContentTree extends Component {
changeContainerWidth({ clientX }) {
const currentPositionX = clientX;

this.setState((state) => ({
resizedContainerWidth: state.containerWidth + (currentPositionX - state.resizeStartPositionX),
}));
this.setState(
(state) => ({
resizedContainerWidth: state.containerWidth + (currentPositionX - state.resizeStartPositionX),
}),
() => {
document.body.dispatchEvent(new CustomEvent('ibexa-main-menu-resized'));
}
);
}

toggleCollapseTree() {
const width = this.checkIsTreeCollapsed() ? EXPANDED_WIDTH : COLLAPSED_WIDTH;

this.setState(() => ({
resizedContainerWidth: width,
containerWidth: width,
}));
this.setState(
() => ({
resizedContainerWidth: width,
containerWidth: width,
}),
() => {
document.body.dispatchEvent(new CustomEvent('ibexa-main-menu-resized'));
}
);
}

addWidthChangeListener({ nativeEvent }) {
Expand All @@ -117,11 +127,16 @@ export default class ContentTree extends Component {
handleResizeEnd() {
this.clearDocumentResizingListeners();

this.setState((state) => ({
resizeStartPositionX: 0,
containerWidth: state.resizedContainerWidth,
isResizing: false,
}));
this.setState(
(state) => ({
resizeStartPositionX: 0,
containerWidth: state.resizedContainerWidth,
isResizing: false,
}),
() => {
document.body.dispatchEvent(new CustomEvent('ibexa-main-menu-resized'));
}
);
}

clearDocumentResizingListeners() {
Expand All @@ -134,22 +149,20 @@ export default class ContentTree extends Component {
const CollapseAction = () => {
const collapseAllLabel = Translator.trans(/*@Desc("Collapse all")*/ 'collapse_all', {}, 'content_tree');

return (
<div onClick={this.props.onCollapseAllItems}>
{collapseAllLabel}
</div>
);
}
return <div onClick={this.props.onCollapseAllItems}>{collapseAllLabel}</div>;
};

return CollapseAction;
}

renderHeader() {
const actions = [{
id: 'collapse-all',
priority: 0,
component: this.getCollapseAllBtn(),
}];
const actions = [
{
id: 'collapse-all',
priority: 0,
component: this.getCollapseAllBtn(),
},
];

return (
<Header
Expand All @@ -158,7 +171,7 @@ export default class ContentTree extends Component {
popupRef={this._refPopupContainer}
actions={actions}
/>
)
);
}

renderList() {
Expand Down