Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit a7c15b2

Browse files
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). <!-- Please read https://github.com/matrix-org/matrix-js-sdk/blob/develop/CONTRIBUTING.md before submitting your pull request --> <!-- Include a Sign-Off as described in https://github.com/matrix-org/matrix-js-sdk/blob/develop/CONTRIBUTING.md#sign-off --> `Signed-off-by: Andrew Morgan <[email protected]>`
1 parent 94af6db commit a7c15b2

File tree

2 files changed

+42
-29
lines changed

2 files changed

+42
-29
lines changed

src/components/structures/ContextMenu.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ export interface IProps extends IPosition {
8080
managed?: boolean;
8181
wrapperClassName?: string;
8282

83+
// If true, this context menu will be mounted as a child to the parent container. Otherwise
84+
// it will be mounted to a container at the root of the DOM.
85+
mountAsChild?: boolean;
86+
8387
// Function to be called on menu close
8488
onFinished();
8589
// on resize callback
@@ -390,7 +394,13 @@ export class ContextMenu extends React.PureComponent<IProps, IState> {
390394
}
391395

392396
render(): React.ReactChild {
393-
return ReactDOM.createPortal(this.renderMenu(), getOrCreateContainer());
397+
if (this.props.mountAsChild) {
398+
// Render as a child of the current parent
399+
return this.renderMenu();
400+
} else {
401+
// Render as a child of a container at the root of the DOM
402+
return ReactDOM.createPortal(this.renderMenu(), getOrCreateContainer());
403+
}
394404
}
395405
}
396406

src/components/views/voip/CallView.tsx

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export default class CallView extends React.Component<IProps, IState> {
115115
private controlsHideTimer: number = null;
116116
private dialpadButton = createRef<HTMLDivElement>();
117117
private contextMenuButton = createRef<HTMLDivElement>();
118+
private contextMenu = createRef<HTMLDivElement>();
118119

119120
constructor(props: IProps) {
120121
super(props);
@@ -545,12 +546,42 @@ export default class CallView extends React.Component<IProps, IState> {
545546
);
546547
}
547548

549+
let dialPad;
550+
if (this.state.showDialpad) {
551+
dialPad = <DialpadContextMenu
552+
{...alwaysAboveRightOf(
553+
this.dialpadButton.current.getBoundingClientRect(),
554+
ChevronFace.None,
555+
CONTEXT_MENU_VPADDING,
556+
)}
557+
mountAsChild={true}
558+
onFinished={this.closeDialpad}
559+
call={this.props.call}
560+
/>;
561+
}
562+
563+
let contextMenu;
564+
if (this.state.showMoreMenu) {
565+
contextMenu = <CallContextMenu
566+
{...alwaysAboveLeftOf(
567+
this.contextMenuButton.current.getBoundingClientRect(),
568+
ChevronFace.None,
569+
CONTEXT_MENU_VPADDING,
570+
)}
571+
mountAsChild={true}
572+
onFinished={this.closeContextMenu}
573+
call={this.props.call}
574+
/>;
575+
}
576+
548577
return (
549578
<div
550579
className={callControlsClasses}
551580
onMouseEnter={this.onCallControlsMouseEnter}
552581
onMouseLeave={this.onCallControlsMouseLeave}
553582
>
583+
{ dialPad }
584+
{ contextMenu }
554585
{ dialpadButton }
555586
<AccessibleButton
556587
className={micClasses}
@@ -858,37 +889,9 @@ export default class CallView extends React.Component<IProps, IState> {
858889
myClassName = 'mx_CallView_pip';
859890
}
860891

861-
let dialPad;
862-
if (this.state.showDialpad) {
863-
dialPad = <DialpadContextMenu
864-
{...alwaysAboveRightOf(
865-
this.dialpadButton.current.getBoundingClientRect(),
866-
ChevronFace.None,
867-
CONTEXT_MENU_VPADDING,
868-
)}
869-
onFinished={this.closeDialpad}
870-
call={this.props.call}
871-
/>;
872-
}
873-
874-
let contextMenu;
875-
if (this.state.showMoreMenu) {
876-
contextMenu = <CallContextMenu
877-
{...alwaysAboveLeftOf(
878-
this.contextMenuButton.current.getBoundingClientRect(),
879-
ChevronFace.None,
880-
CONTEXT_MENU_VPADDING,
881-
)}
882-
onFinished={this.closeContextMenu}
883-
call={this.props.call}
884-
/>;
885-
}
886-
887892
return <div className={"mx_CallView " + myClassName}>
888893
{ header }
889894
{ contentView }
890-
{ dialPad }
891-
{ contextMenu }
892895
</div>;
893896
}
894897
}

0 commit comments

Comments
 (0)