From c7f07f4c290ba4ca1488398bd0c7e3434ceea3fc Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 31 Oct 2025 09:00:01 +0000 Subject: [PATCH] Fix tooltips within context menu portals being unreliable (#31129) * Fix tooltips within context menu portals being unreliable Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update snapshots Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add test Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/ContextMenu.tsx | 21 +++--- .../views/rooms/ReadReceiptGroup.tsx | 67 ++++++++++--------- .../views/rooms/ReadReceiptGroup-test.tsx | 5 ++ .../ReadReceiptGroup-test.tsx.snap | 49 ++++++++++++-- 4 files changed, 97 insertions(+), 45 deletions(-) diff --git a/src/components/structures/ContextMenu.tsx b/src/components/structures/ContextMenu.tsx index bdbd8b4a08..eebd432e10 100644 --- a/src/components/structures/ContextMenu.tsx +++ b/src/components/structures/ContextMenu.tsx @@ -12,6 +12,7 @@ import React, { type JSX, type CSSProperties, type RefObject, type SyntheticEven import ReactDOM from "react-dom"; import classNames from "classnames"; import FocusLock from "react-focus-lock"; +import { TooltipProvider } from "@vector-im/compound-web"; import { type Writeable } from "../../@types/common"; import UIStore from "../../stores/UIStore"; @@ -425,15 +426,17 @@ export default class ContextMenu extends React.PureComponent {background} -
- {body} -
+ +
+ {body} +
+
)} diff --git a/src/components/views/rooms/ReadReceiptGroup.tsx b/src/components/views/rooms/ReadReceiptGroup.tsx index 22d2f03697..910e0cfb52 100644 --- a/src/components/views/rooms/ReadReceiptGroup.tsx +++ b/src/components/views/rooms/ReadReceiptGroup.tsx @@ -212,38 +212,41 @@ export function ReadReceiptPerson({ onAfterClick, }: ReadReceiptPersonProps): JSX.Element { return ( - -
- { - dis.dispatch({ - action: Action.ViewUser, - // XXX: We should be using a real member object and not assuming what the receiver wants. - // The ViewUser action leads to the RightPanelStore, and RightPanelStoreIPanelState defines the - // member property of IRightPanelCardState as `RoomMember | User`, so we’re fine for now, but we - // should definitely clean this up later - member: roomMember ?? ({ userId } as User), - push: false, - }); - onAfterClick?.(); - }} - > - -
+ + { + dis.dispatch({ + action: Action.ViewUser, + // XXX: We should be using a real member object and not assuming what the receiver wants. + // The ViewUser action leads to the RightPanelStore, and RightPanelStoreIPanelState defines the + // member property of IRightPanelCardState as `RoomMember | User`, so we’re fine for now, but we + // should definitely clean this up later + member: roomMember ?? ({ userId } as User), + push: false, + }); + onAfterClick?.(); + }} + > + ); } diff --git a/test/unit-tests/components/views/rooms/ReadReceiptGroup-test.tsx b/test/unit-tests/components/views/rooms/ReadReceiptGroup-test.tsx index 0a3cfafb85..0af49f767d 100644 --- a/test/unit-tests/components/views/rooms/ReadReceiptGroup-test.tsx +++ b/test/unit-tests/components/views/rooms/ReadReceiptGroup-test.tsx @@ -142,5 +142,10 @@ describe("ReadReceiptGroup", () => { }), ); }); + + it("should fall back to userId if roomMember unspecified", async () => { + const { container } = renderReadReceipt({ roomMember: null }); + expect(container).toMatchSnapshot(); + }); }); }); diff --git a/test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap b/test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap index 6540cb658c..34802ccce9 100644 --- a/test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap +++ b/test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap @@ -6,14 +6,14 @@ exports[`ReadReceiptGroup should display a tooltip 1`] = ` data-floating-ui-focusable="" id="_r_6_" role="tooltip" - style="position: absolute; left: 0px; top: 0px; transform: translate(0px, 0px);" + style="position: absolute; left: 0px; top: 0px; transform: translate(5px, -6px);" tabindex="-1" >
+ + + +
+`; + exports[`ReadReceiptGroup should render 1`] = `
-
+
-
+ `;