Skip to content

Commit

Permalink
fix(Popup): Invalid reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
hristoterezov committed Jun 28, 2023
1 parent fab8a98 commit 6187bb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions react/features/base/popover/components/Popover.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class Popover extends Component<IProps, IState> {
// Use the `enabled` prop instead of conditionally rendering ReactFocusOn
// to prevent UI stutter on dialog appearance. It seems the focus guards generated annoy
// our DialogPortal positioning calculations.
enabled = { this.state.enableFocusLock }
enabled = { Boolean(this._contextMenuRef) && this.state.enableFocusLock }
returnFocus = {

// If we return the focus to an element outside the viewport the page will scroll to
Expand All @@ -294,7 +294,7 @@ class Popover extends Component<IProps, IState> {
// large video.
isElementInTheViewport
}
shards = { [ this._contextMenuRef ] }>
shards = { this._contextMenuRef && [ this._contextMenuRef ] }>
{this._renderContent()}
</FocusOn>
</DialogPortal>
Expand Down Expand Up @@ -325,7 +325,9 @@ class Popover extends Component<IProps, IState> {
* @returns {void}
*/
_setContextMenuRef(elem: HTMLElement) {
this._contextMenuRef = elem;
if (!elem || document.body.contains(elem)) {
this._contextMenuRef = elem;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion react/features/toolbox/components/web/DialogPortal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function DialogPortal({ children, className, style, getRef, setSize, targetSelec
getRef(portalTarget);
portalTarget.style.zIndex = `${ZINDEX_DIALOG_PORTAL}`;
}
}, [ portalTarget ]);
}, [ portalTarget, getRef ]);

useEffect(() => {
const size = {
Expand Down

0 comments on commit 6187bb9

Please sign in to comment.