From 20f51fe088d2b130bddff7b34cbe2b8fc5193911 Mon Sep 17 00:00:00 2001 From: Dariusz Szut Date: Tue, 14 Dec 2021 11:33:25 +0100 Subject: [PATCH] IBX-1684: Added adapt context menu when content tree is resized --- .../components/content-tree/content.tree.js | 61 +++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/src/bundle/ui-dev/src/modules/content-tree/components/content-tree/content.tree.js b/src/bundle/ui-dev/src/modules/content-tree/components/content-tree/content.tree.js index 35dfd8d22a..ae1944b0c4 100644 --- a/src/bundle/ui-dev/src/modules/content-tree/components/content-tree/content.tree.js +++ b/src/bundle/ui-dev/src/modules/content-tree/components/content-tree/content.tree.js @@ -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 }) { @@ -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() { @@ -134,22 +149,20 @@ export default class ContentTree extends Component { const CollapseAction = () => { const collapseAllLabel = Translator.trans(/*@Desc("Collapse all")*/ 'collapse_all', {}, 'content_tree'); - return ( -
- {collapseAllLabel} -
- ); - } + return
{collapseAllLabel}
; + }; return CollapseAction; } renderHeader() { - const actions = [{ - id: 'collapse-all', - priority: 0, - component: this.getCollapseAllBtn(), - }]; + const actions = [ + { + id: 'collapse-all', + priority: 0, + component: this.getCollapseAllBtn(), + }, + ]; return (
- ) + ); } renderList() {