From a7c15b2ac05a2ffadd34183ac58b640131f586c9 Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Thu, 29 Jul 2021 17:51:27 +0100 Subject: [PATCH] Fix DialPad and Call Menu buttons not working when a call is fullscreened. (#6496) This PR: * Moves the dialpad and hold/transfer menu buttons into the part of the DOM that's included when a call is fullscreen'd. * Tweaks `ContextMenu` to allow menu content to be mount as a child of the current component, rather than at the root of the DOM (which was not included in the full-screen'd content). `Signed-off-by: Andrew Morgan ` --- src/components/structures/ContextMenu.tsx | 12 ++++- src/components/views/voip/CallView.tsx | 59 ++++++++++++----------- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/components/structures/ContextMenu.tsx b/src/components/structures/ContextMenu.tsx index 407dc6f04c..01c086b73c 100644 --- a/src/components/structures/ContextMenu.tsx +++ b/src/components/structures/ContextMenu.tsx @@ -80,6 +80,10 @@ export interface IProps extends IPosition { managed?: boolean; wrapperClassName?: string; + // If true, this context menu will be mounted as a child to the parent container. Otherwise + // it will be mounted to a container at the root of the DOM. + mountAsChild?: boolean; + // Function to be called on menu close onFinished(); // on resize callback @@ -390,7 +394,13 @@ export class ContextMenu extends React.PureComponent { } render(): React.ReactChild { - return ReactDOM.createPortal(this.renderMenu(), getOrCreateContainer()); + if (this.props.mountAsChild) { + // Render as a child of the current parent + return this.renderMenu(); + } else { + // Render as a child of a container at the root of the DOM + return ReactDOM.createPortal(this.renderMenu(), getOrCreateContainer()); + } } } diff --git a/src/components/views/voip/CallView.tsx b/src/components/views/voip/CallView.tsx index 481d7b303c..356e642d65 100644 --- a/src/components/views/voip/CallView.tsx +++ b/src/components/views/voip/CallView.tsx @@ -115,6 +115,7 @@ export default class CallView extends React.Component { private controlsHideTimer: number = null; private dialpadButton = createRef(); private contextMenuButton = createRef(); + private contextMenu = createRef(); constructor(props: IProps) { super(props); @@ -545,12 +546,42 @@ export default class CallView extends React.Component { ); } + let dialPad; + if (this.state.showDialpad) { + dialPad = ; + } + + let contextMenu; + if (this.state.showMoreMenu) { + contextMenu = ; + } + return (
+ { dialPad } + { contextMenu } { dialpadButton } { myClassName = 'mx_CallView_pip'; } - let dialPad; - if (this.state.showDialpad) { - dialPad = ; - } - - let contextMenu; - if (this.state.showMoreMenu) { - contextMenu = ; - } - return
{ header } { contentView } - { dialPad } - { contextMenu }
; } }