From 2212fbadd07ea1a7de82b3294e2baa1367a6c170 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 19 Dec 2023 17:19:54 +0000 Subject: [PATCH] Use Compound tooltips instead of homegrown in TextWithTooltip & InfoTooltip (#12052) * Migrate InfoTooltip to use Compound Tooltip Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Migrate DecoratedRoomAvatar.tsx to Compound tooltips Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Small type tweaks Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove unused props Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Migrate TextWithTooltip.tsx to Compound tooltips This adds `contain: strict` to #matrixchat which may have side effects. Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update snapshots Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add comment Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update snapshot Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Revert accidental layout change to TextWithTooltip from inline to block Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve test coverage and simplify Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update snapshots Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Ditch the sleep call Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve coverage Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- res/css/_common.pcss | 5 ++ .../views/avatars/DecoratedRoomAvatar.tsx | 22 +++---- .../views/dialogs/ServerPickerDialog.tsx | 2 +- .../views/elements/AppPermission.tsx | 13 ++-- src/components/views/elements/InfoTooltip.tsx | 33 ++++------ .../views/elements/ServerPicker.tsx | 2 +- .../views/elements/TextWithTooltip.tsx | 31 ++++----- src/components/views/rooms/RoomList.tsx | 3 - src/toasts/IncomingCallToast.tsx | 2 +- .../SpaceHierarchy-test.tsx.snap | 12 ++-- .../avatars/DecoratedRoomAvatar-test.tsx | 66 +++++++++++++++++++ .../DecoratedRoomAvatar-test.tsx.snap | 26 ++++++++ .../ServerPickerDialog-test.tsx.snap | 8 +-- .../views/elements/InfoTooltip-test.tsx | 41 ++++++++++++ .../__snapshots__/InfoTooltip-test.tsx.snap | 18 +++++ 15 files changed, 209 insertions(+), 75 deletions(-) create mode 100644 test/components/views/avatars/DecoratedRoomAvatar-test.tsx create mode 100644 test/components/views/avatars/__snapshots__/DecoratedRoomAvatar-test.tsx.snap create mode 100644 test/components/views/elements/InfoTooltip-test.tsx create mode 100644 test/components/views/elements/__snapshots__/InfoTooltip-test.tsx.snap diff --git a/res/css/_common.pcss b/res/css/_common.pcss index 020767b0ec..29bb165e7b 100644 --- a/res/css/_common.pcss +++ b/res/css/_common.pcss @@ -52,6 +52,11 @@ limitations under the License. --dialog-zIndex-standard: calc(var(--dialog-zIndex-standard-background) + 1); /* 4012 */ } +#matrixchat { + /* This is required to ensure Compound tooltips correctly draw where they should with z-index: auto */ + contain: strict; +} + /** * We need to increase the specificity of the selector to override the * custom property set by the design tokens package diff --git a/src/components/views/avatars/DecoratedRoomAvatar.tsx b/src/components/views/avatars/DecoratedRoomAvatar.tsx index 39997e186d..0afc131735 100644 --- a/src/components/views/avatars/DecoratedRoomAvatar.tsx +++ b/src/components/views/avatars/DecoratedRoomAvatar.tsx @@ -16,8 +16,9 @@ limitations under the License. import React from "react"; import classNames from "classnames"; -import { Room, RoomEvent, MatrixEvent, User, UserEvent, EventType, JoinRule } from "matrix-js-sdk/src/matrix"; +import { EventType, JoinRule, MatrixEvent, Room, RoomEvent, User, UserEvent } from "matrix-js-sdk/src/matrix"; import { UnstableValue } from "matrix-js-sdk/src/NamespacedValue"; +import { Tooltip } from "@vector-im/compound-web"; import RoomAvatar from "./RoomAvatar"; import NotificationBadge from "../rooms/NotificationBadge"; @@ -26,10 +27,8 @@ import { NotificationState } from "../../../stores/notifications/NotificationSta import { isPresenceEnabled } from "../../../utils/presence"; import { MatrixClientPeg } from "../../../MatrixClientPeg"; import { _t } from "../../../languageHandler"; -import TextWithTooltip from "../elements/TextWithTooltip"; import DMRoomMap from "../../../utils/DMRoomMap"; import { IOOBData } from "../../../stores/ThreepidInviteStore"; -import TooltipTarget from "../elements/TooltipTarget"; interface IProps { room: Room; @@ -38,7 +37,9 @@ interface IProps { forceCount?: boolean; oobData?: IOOBData; viewAvatarOnClick?: boolean; - tooltipProps?: Omit, "label" | "tooltipClassName" | "className">; + tooltipProps?: { + tabIndex?: number; + }; } interface IState { @@ -94,9 +95,7 @@ export default class DecoratedRoomAvatar extends React.PureComponent ); } @@ -211,7 +209,7 @@ export default class DecoratedRoomAvatar extends React.PureComponent - {icon} + {icon && {icon}} {badge} ); diff --git a/src/components/views/dialogs/ServerPickerDialog.tsx b/src/components/views/dialogs/ServerPickerDialog.tsx index 793cfcf27a..ee8a3751da 100644 --- a/src/components/views/dialogs/ServerPickerDialog.tsx +++ b/src/components/views/dialogs/ServerPickerDialog.tsx @@ -182,7 +182,7 @@ export default class ServerPickerDialog extends React.PureComponent