Improve strictNullChecks support in right_panel (#10415)

This commit is contained in:
Andy Balaam 2023-03-22 12:15:26 +00:00 committed by GitHub
parent 853b3f822d
commit ba36d2cc01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 63 additions and 52 deletions

View file

@ -57,12 +57,14 @@ const WidgetCard: React.FC<IProps> = ({ room, widgetId, onClose }) => {
let contextMenu: JSX.Element | undefined;
if (menuDisplayed) {
const rect = handle.current!.getBoundingClientRect();
const rect = handle.current?.getBoundingClientRect();
const rightMargin = rect ? rect.right : 0;
const bottomMargin = rect ? rect.bottom : 0;
contextMenu = (
<WidgetContextMenu
chevronFace={ChevronFace.None}
right={UIStore.instance.windowWidth - rect.right - 12}
top={rect.bottom + 12}
right={UIStore.instance.windowWidth - rightMargin - 12}
top={bottomMargin + 12}
onFinished={closeMenu}
app={app}
/>