diff --git a/packages/flat-pages/src/components/Shortcuts/Shortcuts.tsx b/packages/flat-pages/src/components/Shortcuts/Shortcuts.tsx index f3a93344d2d..0729482a66d 100644 --- a/packages/flat-pages/src/components/Shortcuts/Shortcuts.tsx +++ b/packages/flat-pages/src/components/Shortcuts/Shortcuts.tsx @@ -26,7 +26,7 @@ export const Shortcuts = observer(function Shortcuts({ classroom ); const { height: windowHeight } = useWindowSize(); const rect = useBoundingRect(target); - const isAvatarWindow = useMemo(() => target?.classList.contains("window-main"), [target]); + const isAvatarWindow = useMemo(() => hasAncestorWithClassName(target, "window-main"), [target]); const style = useMemo( () => rect && activeUser @@ -155,3 +155,13 @@ export const Shortcuts = observer(function Shortcuts({ classroom ); }); + +function hasAncestorWithClassName(el: HTMLElement | null, className: string): boolean { + if (!el) { + return false; + } + if (el.classList.contains(className)) { + return true; + } + return hasAncestorWithClassName(el.parentElement, className); +}