Skip to content

Commit 31af8b0

Browse files
authored
Remove buggy tooltip on room intro & homepage (#29406)
* Remove buggy tooltip on room intro & homepage Signed-off-by: Michael Telatynski <[email protected]> * Add knip ignore Signed-off-by: Michael Telatynski <[email protected]> --------- Signed-off-by: Michael Telatynski <[email protected]>
1 parent 21e9d93 commit 31af8b0

File tree

3 files changed

+19
-31
lines changed

3 files changed

+19
-31
lines changed

knip.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default {
1919
ignore: [
2020
// Keep for now
2121
"src/hooks/useLocalStorageState.ts",
22+
"src/hooks/useTimeout.ts",
2223
"src/components/views/elements/InfoTooltip.tsx",
2324
"src/components/views/elements/StyledCheckbox.tsx",
2425
],

src/components/views/elements/MiniAvatarUploader.tsx

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ Please see LICENSE files in the repository root for full details.
99
import classNames from "classnames";
1010
import { EventType } from "matrix-js-sdk/src/matrix";
1111
import React, { useContext, useRef, useState, type MouseEvent, type ReactNode } from "react";
12-
import { Tooltip } from "@vector-im/compound-web";
1312

1413
import MatrixClientContext from "../../../contexts/MatrixClientContext";
15-
import { useTimeout } from "../../../hooks/useTimeout";
1614
import { chromeFileInputFix } from "../../../utils/BrowserWorkarounds";
1715
import AccessibleButton from "./AccessibleButton";
1816
import Spinner from "./Spinner";
@@ -42,15 +40,6 @@ const MiniAvatarUploader: React.FC<IProps> = ({
4240
}) => {
4341
const cli = useContext(MatrixClientContext);
4442
const [busy, setBusy] = useState(false);
45-
const [hover, setHover] = useState(false);
46-
const [show, setShow] = useState(false);
47-
48-
useTimeout(() => {
49-
setShow(true);
50-
}, 3000); // show after 3 seconds
51-
useTimeout(() => {
52-
setShow(false);
53-
}, 13000); // hide after being shown for 10 seconds
5443

5544
const uploadRef = useRef<HTMLInputElement>(null);
5645

@@ -61,7 +50,6 @@ const MiniAvatarUploader: React.FC<IProps> = ({
6150
isUserAvatar || room?.currentState?.maySendStateEvent(EventType.RoomAvatar, cli.getSafeUserId());
6251
if (!canSetAvatar) return <React.Fragment>{children}</React.Fragment>;
6352

64-
const visible = !!label && (hover || show);
6553
return (
6654
<React.Fragment>
6755
<input
@@ -84,24 +72,23 @@ const MiniAvatarUploader: React.FC<IProps> = ({
8472
accept="image/*"
8573
/>
8674

87-
<Tooltip label={label!} open={visible} onOpenChange={setHover}>
88-
<AccessibleButton
89-
className={classNames("mx_MiniAvatarUploader", {
90-
mx_MiniAvatarUploader_busy: busy,
91-
mx_MiniAvatarUploader_hasAvatar: hasAvatar,
92-
})}
93-
disabled={busy}
94-
onClick={() => {
95-
uploadRef.current?.click();
96-
}}
97-
>
98-
{children}
75+
<AccessibleButton
76+
className={classNames("mx_MiniAvatarUploader", {
77+
mx_MiniAvatarUploader_busy: busy,
78+
mx_MiniAvatarUploader_hasAvatar: hasAvatar,
79+
})}
80+
disabled={busy}
81+
onClick={() => {
82+
uploadRef.current?.click();
83+
}}
84+
aria-label={label}
85+
>
86+
{children}
9987

100-
<div className="mx_MiniAvatarUploader_indicator">
101-
{busy ? <Spinner w={20} h={20} /> : <div className="mx_MiniAvatarUploader_cameraIcon" />}
102-
</div>
103-
</AccessibleButton>
104-
</Tooltip>
88+
<div className="mx_MiniAvatarUploader_indicator">
89+
{busy ? <Spinner w={20} h={20} /> : <div className="mx_MiniAvatarUploader_cameraIcon" />}
90+
</div>
91+
</AccessibleButton>
10592
</React.Fragment>
10693
);
10794
};

test/unit-tests/components/views/elements/MiniAvatarUploader-test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ describe("<MiniAvatarUploader />", () => {
2626
const setAvatarUrl = jest.fn();
2727
const user = userEvent.setup();
2828

29-
const { container, findByText } = render(
29+
const { container, findByLabelText } = render(
3030
<MiniAvatarUploader hasAvatar={false} noAvatarLabel="Upload" setAvatarUrl={setAvatarUrl} isUserAvatar />,
3131
withClientContextRenderOptions(cli),
3232
);
3333

34-
await findByText("Upload");
34+
await findByLabelText("Upload");
3535
await user.upload(container.querySelector("input")!, AVATAR_FILE);
3636

3737
expect(cli.uploadContent).toHaveBeenCalledWith(AVATAR_FILE);

0 commit comments

Comments
 (0)