From 92ea1157bec969006882e87f38f8d9c35a7b5ce1 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 23 Dec 2019 19:26:59 -0700 Subject: [PATCH] Reintroduce working resizer code for right panel Fixes https://github.com/vector-im/riot-web/issues/11674 This re-introduces and adapted version of what was there before, but fixed for the new collapsed logic: https://github.com/matrix-org/matrix-react-sdk/pull/3703/files#diff-633a0248e235d7446a8868a9145efce2L77-L93 We no longer have a collapsedRhs variable and only set the panel when it is opened, so we can accurately track expanded/collapsed state through presence of a panel. --- src/components/structures/MainSplit.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/components/structures/MainSplit.js b/src/components/structures/MainSplit.js index bd7bfd8780..772be358cf 100644 --- a/src/components/structures/MainSplit.js +++ b/src/components/structures/MainSplit.js @@ -74,6 +74,21 @@ export default class MainSplit extends React.Component { } } + componentDidUpdate(prevProps) { + const wasPanelSet = this.props.panel && !prevProps.panel; + const wasPanelCleared = !this.props.panel && prevProps.panel; + + if (this.resizeContainer && wasPanelSet) { + // The resizer can only be created when **both** expanded and the panel is + // set. Once both are true, the container ref will mount, which is required + // for the resizer to work. + this._createResizer(); + } else if (this.resizer && wasPanelCleared) { + this.resizer.detach(); + this.resizer = null; + } + } + render() { const bodyView = React.Children.only(this.props.children); const panelView = this.props.panel;