diff --git a/src/components/views/elements/RoomTopic.tsx b/src/components/views/elements/RoomTopic.tsx
index eb9ae028a4..02a9bfe2d7 100644
--- a/src/components/views/elements/RoomTopic.tsx
+++ b/src/components/views/elements/RoomTopic.tsx
@@ -103,10 +103,17 @@ export default function RoomTopic({ room, ...props }: IProps): JSX.Element {
const className = classNames(props.className, "mx_RoomTopic");
return (
-
-
- {body}
-
-
+
+ {body}
+
);
}
diff --git a/src/components/views/elements/TooltipTarget.tsx b/src/components/views/elements/TooltipTarget.tsx
index a8c773d1f6..cbd0555d38 100644
--- a/src/components/views/elements/TooltipTarget.tsx
+++ b/src/components/views/elements/TooltipTarget.tsx
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import React, { HTMLAttributes } from "react";
+import React, { forwardRef, HTMLAttributes } from "react";
import useFocus from "../../../hooks/useFocus";
import useHover from "../../../hooks/useHover";
@@ -29,49 +29,55 @@ interface IProps extends HTMLAttributes, Omit = ({
- children,
- tooltipTargetClassName,
- // tooltip pass through props
- className,
- id,
- label,
- alignment,
- tooltipClassName,
- maxParentWidth,
- ignoreHover,
- ...rest
-}) => {
- const [isFocused, focusProps] = useFocus();
- const [isHovering, hoverProps] = useHover(ignoreHover || (() => false));
+const TooltipTarget = forwardRef(
+ (
+ {
+ children,
+ tooltipTargetClassName,
+ // tooltip pass through props
+ className,
+ id,
+ label,
+ alignment,
+ tooltipClassName,
+ maxParentWidth,
+ ignoreHover,
+ ...rest
+ },
+ ref,
+ ) => {
+ const [isFocused, focusProps] = useFocus();
+ const [isHovering, hoverProps] = useHover(ignoreHover || (() => false));
- // No need to fill up the DOM with hidden tooltip elements. Only add the
- // tooltip when we're hovering over the item (performance)
- const tooltip = (isFocused || isHovering) && (
-
- );
+ // No need to fill up the DOM with hidden tooltip elements. Only add the
+ // tooltip when we're hovering over the item (performance)
+ const tooltip = (isFocused || isHovering) && (
+
+ );
- return (
-
- {children}
- {tooltip}
-
- );
-};
+ return (
+
+ {children}
+ {tooltip}
+
+ );
+ },
+);
export default TooltipTarget;
diff --git a/test/PosthogAnalytics-test.ts b/test/PosthogAnalytics-test.ts
index e0b47e028e..61a46a5405 100644
--- a/test/PosthogAnalytics-test.ts
+++ b/test/PosthogAnalytics-test.ts
@@ -52,24 +52,27 @@ describe("PosthogAnalytics", () => {
beforeEach(() => {
fakePosthog = getFakePosthog();
- window.crypto = {
- subtle: {
- digest: async (_: AlgorithmIdentifier, encodedMessage: BufferSource) => {
- const message = new TextDecoder().decode(encodedMessage);
- const hexHash = shaHashes[message];
- const bytes: number[] = [];
- for (let c = 0; c < hexHash.length; c += 2) {
- bytes.push(parseInt(hexHash.slice(c, c + 2), 16));
- }
- return bytes as unknown as ArrayBuffer;
+ Object.defineProperty(window, "crypto", {
+ value: {
+ subtle: {
+ digest: async (_: AlgorithmIdentifier, encodedMessage: BufferSource) => {
+ const message = new TextDecoder().decode(encodedMessage);
+ const hexHash = shaHashes[message];
+ const bytes: number[] = [];
+ for (let c = 0; c < hexHash.length; c += 2) {
+ bytes.push(parseInt(hexHash.slice(c, c + 2), 16));
+ }
+ return bytes;
+ },
},
- } as unknown as SubtleCrypto,
- } as unknown as Crypto;
+ },
+ });
});
afterEach(() => {
- // @ts-ignore
- window.crypto = null;
+ Object.defineProperty(window, "crypto", {
+ value: null,
+ });
SdkConfig.unset(); // we touch the config, so clean up
});
diff --git a/test/components/structures/__snapshots__/RoomView-test.tsx.snap b/test/components/structures/__snapshots__/RoomView-test.tsx.snap
index d32c9a75d7..b1a6c4ea5d 100644
--- a/test/components/structures/__snapshots__/RoomView-test.tsx.snap
+++ b/test/components/structures/__snapshots__/RoomView-test.tsx.snap
@@ -55,14 +55,11 @@ exports[`RoomView for a local room in state CREATING should match the snapshot 1
@@ -149,14 +146,11 @@ exports[`RoomView for a local room in state ERROR should match the snapshot 1`]
@@ -339,14 +333,11 @@ exports[`RoomView for a local room in state NEW should match the snapshot 1`] =
@@ -606,14 +597,11 @@ exports[`RoomView for a local room in state NEW that is encrypted should match t
diff --git a/test/utils/MegolmExportEncryption-test.ts b/test/utils/MegolmExportEncryption-test.ts
index 69d803073f..e3e6d8ca24 100644
--- a/test/utils/MegolmExportEncryption-test.ts
+++ b/test/utils/MegolmExportEncryption-test.ts
@@ -75,13 +75,13 @@ describe("MegolmExportEncryption", function () {
let MegolmExportEncryption: typeof MegolmExportEncryptionExport;
beforeEach(() => {
- window.crypto = {
- getRandomValues,
- randomUUID: jest.fn().mockReturnValue("not-random-uuid"),
- subtle: webCrypto.subtle,
- };
- // @ts-ignore for some reason including it in the object above gets ignored
- window.crypto.subtle = webCrypto.subtle;
+ Object.defineProperty(window, "crypto", {
+ value: {
+ getRandomValues,
+ randomUUID: jest.fn().mockReturnValue("not-random-uuid"),
+ subtle: webCrypto.subtle,
+ },
+ });
MegolmExportEncryption = require("../../src/utils/MegolmExportEncryption");
});