Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Tooltip: migrate remaining tooltips from AccessibleTooltipButton to AccessibleButton #12522

Merged
merged 37 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2a7f500
Use `AccessibleButton` in `RovingAccessibleTooltipButton`
florianduros Apr 26, 2024
f3b8703
Update snapshots
florianduros Apr 26, 2024
ac2f39b
Update @vector-im/compound-web
florianduros Apr 26, 2024
7f086b8
Update composer
florianduros Apr 26, 2024
d84f003
Update formating buttons
florianduros Apr 26, 2024
4573d17
Update snapshots
florianduros Apr 26, 2024
e0d6e34
Update `ContextMenuTooltipButton.tsx`
florianduros Apr 29, 2024
0d349ca
Fix placement
florianduros Apr 29, 2024
9d7e7ee
Update tests
florianduros Apr 29, 2024
3f498b2
Merge branch 'develop' into florianduros/tooltip/context-menu
florianduros Apr 29, 2024
5d9a17d
Merge branch 'develop' into florianduros/tooltip/context-menu
florianduros Apr 30, 2024
b6e8e15
Merge branch 'refs/heads/develop' into florianduros/tooltip/composer
florianduros Apr 30, 2024
5c8dc3b
Merge branch 'develop' into florianduros/tooltip/context-menu
florianduros Apr 30, 2024
bc88c82
Remove placement
florianduros Apr 30, 2024
fcd5c46
Merge branch 'refs/heads/develop' into florianduros/tooltip/context-menu
florianduros May 2, 2024
18165a9
Update space panel snapshot
florianduros May 2, 2024
3ebaee7
Remove default placement
florianduros May 2, 2024
b8d46ee
Merge branch 'refs/heads/develop' into florianduros/tooltip/context-menu
florianduros May 6, 2024
85208f1
Update snapshots
florianduros May 6, 2024
1e65c3d
Merge branch 'refs/heads/develop' into florianduros/tooltip/composer
florianduros May 6, 2024
ba3289b
Update snapshots
florianduros May 6, 2024
64f1ab0
Use kbd
florianduros May 7, 2024
d66b615
Update ``@vector-im/compound-web`
florianduros May 7, 2024
5c8f0ad
Merge branch 'develop' into florianduros/tooltip/composer
florianduros May 14, 2024
321aa78
Merge branch 'refs/heads/develop' into florianduros/tooltip/context-menu
florianduros May 14, 2024
5b5e979
Merge branch 'refs/heads/florianduros/tooltip/composer' into floriand…
florianduros May 14, 2024
2472e75
Merge branch 'refs/heads/florianduros/tooltip/context-menu' into flor…
florianduros May 14, 2024
b9bc915
Migrate remaining files
florianduros May 14, 2024
990d03c
Remove `AccessibleTooltipButton.tsx`
florianduros May 14, 2024
8051c9f
Merge branch 'develop' into florianduros/tooltip/misc
florianduros May 15, 2024
fd34eec
Merge branch 'refs/heads/develop' into florianduros/tooltip/misc
florianduros May 15, 2024
835a9ec
Add test to `InteractiveAuthEntryComponents`
florianduros May 15, 2024
13bc2a2
Add test to `InteractiveAuthEntryComponents`
florianduros May 15, 2024
69cf709
Back to old RoomList-test.tsx
florianduros May 15, 2024
07218b4
Merge branch 'develop' into florianduros/tooltip/misc
florianduros May 16, 2024
9d4e139
Improve `InteractiveAuthEntryComponent` tests
florianduros May 17, 2024
ddd9b47
Review changes
florianduros May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/components/views/auth/InteractiveAuthEntryComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ import SettingsStore from "../../../settings/SettingsStore";
import { LocalisedPolicy, Policies } from "../../../Terms";
import { AuthHeaderModifier } from "../../structures/auth/header/AuthHeaderModifier";
import AccessibleButton, { AccessibleButtonKind, ButtonEvent } from "../elements/AccessibleButton";
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
import Field from "../elements/Field";
import Spinner from "../elements/Spinner";
import { Alignment } from "../elements/Tooltip";
import CaptchaForm from "./CaptchaForm";

/* This file contains a collection of components which are used by the
Expand Down Expand Up @@ -501,15 +499,16 @@ export class EmailIdentityAuthEntry extends React.Component<
{},
{
a: (text: string) => (
<AccessibleTooltipButton
<AccessibleButton
kind="link_inline"
title={
this.state.requested ? _t("auth|uia|email_resent") : _t("action|resend")
}
alignment={Alignment.Right}
florianduros marked this conversation as resolved.
Show resolved Hide resolved
onHideTooltip={
onTooltipOpenChange={
this.state.requested
? () => this.setState({ requested: false })
? (open) => {
if (!open) this.setState({ requested: false });
}
: undefined
}
onClick={async (): Promise<void> => {
Expand All @@ -524,7 +523,7 @@ export class EmailIdentityAuthEntry extends React.Component<
}}
>
{text}
</AccessibleTooltipButton>
</AccessibleButton>
),
},
)}
Expand Down
15 changes: 5 additions & 10 deletions src/components/views/beta/BetaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import SdkConfig from "../../../SdkConfig";
import SettingsFlag from "../elements/SettingsFlag";
import { useFeatureEnabled } from "../../../hooks/useSettings";
import InlineSpinner from "../elements/InlineSpinner";
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
import { shouldShowFeedback } from "../../../utils/Feedback";

// XXX: Keep this around for re-use in future Betas
Expand All @@ -50,19 +49,15 @@ export const BetaPill: React.FC<IBetaPillProps> = ({
}) => {
if (onClick) {
return (
<AccessibleTooltipButton
<AccessibleButton
className="mx_BetaCard_betaPill"
title={`${tooltipTitle} ${tooltipCaption}`}
tooltip={
<div>
<div className="mx_Tooltip_title">{tooltipTitle}</div>
<div className="mx_Tooltip_sub">{tooltipCaption}</div>
</div>
}
aria-label={`${tooltipTitle} ${tooltipCaption}`}
title={tooltipTitle}
caption={tooltipCaption}
onClick={onClick}
>
{_t("common|beta")}
</AccessibleTooltipButton>
</AccessibleButton>
);
}

Expand Down
118 changes: 0 additions & 118 deletions src/components/views/elements/AccessibleTooltipButton.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import React, { ComponentProps } from "react";

import { Icon as CaretIcon } from "../../../../../res/img/feather-customised/dropdown-arrow.svg";
import { _t } from "../../../../languageHandler";
import AccessibleTooltipButton from "../../elements/AccessibleTooltipButton";
import AccessibleButton from "../../elements/AccessibleButton";

type Props<T extends keyof JSX.IntrinsicElements> = Omit<
ComponentProps<typeof AccessibleTooltipButton<T>>,
ComponentProps<typeof AccessibleButton<T>>,
"aria-label" | "title" | "kind" | "className" | "onClick" | "element"
> & {
isExpanded: boolean;
Expand All @@ -36,7 +36,7 @@ export const DeviceExpandDetailsButton = <T extends keyof JSX.IntrinsicElements>
}: Props<T>): JSX.Element => {
const label = isExpanded ? _t("settings|sessions|hide_details") : _t("settings|sessions|show_details");
return (
<AccessibleTooltipButton
<AccessibleButton
{...rest}
aria-label={label}
title={label}
Expand All @@ -47,6 +47,6 @@ export const DeviceExpandDetailsButton = <T extends keyof JSX.IntrinsicElements>
onClick={onClick}
>
<CaretIcon className="mx_DeviceExpandDetailsButton_icon" />
</AccessibleTooltipButton>
</AccessibleButton>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright 2024 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import React from "react";
import { render, screen, waitFor, act } from "@testing-library/react";
import { AuthType } from "matrix-js-sdk/src/interactive-auth";
import userEvent from "@testing-library/user-event";

import { EmailIdentityAuthEntry } from "../../../../src/components/views/auth/InteractiveAuthEntryComponents";
import { createTestClient } from "../../../test-utils";

describe("<EmailIdentityAuthEntry/>", () => {
const renderIdentityAuth = () => {
const matrixClient = createTestClient();

return render(
<EmailIdentityAuthEntry
matrixClient={matrixClient}
loginType={AuthType.Email}
onPhaseChange={jest.fn()}
submitAuthDict={jest.fn()}
fail={jest.fn()}
clientSecret="my secret"
showContinue={true}
inputs={{ emailAddress: "[email protected]" }}
/>,
);
};

test("should render", () => {
const { container } = renderIdentityAuth();
expect(container).toMatchSnapshot();
});

test("should clear the requested state when the button tooltip is hidden", async () => {
renderIdentityAuth();

// After a click on the resend button, the button should display the resent label
screen.getByRole("button", { name: "Resend" }).click();
await waitFor(() => expect(screen.queryByRole("button", { name: "Resent!" })).toBeInTheDocument());
expect(screen.queryByRole("button", { name: "Resend" })).toBeNull();

const resentButton = screen.getByRole("button", { name: "Resent!" });
// Hover briefly the button and wait for the tooltip to be displayed
await userEvent.hover(resentButton);
await waitFor(() => expect(screen.getByRole("tooltip", { name: "Resent!" })).toBeInTheDocument());

// On unhover, it should display again the resend button
await act(() => userEvent.unhover(resentButton));
await waitFor(() => expect(screen.queryByRole("button", { name: "Resend" })).toBeInTheDocument());
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<EmailIdentityAuthEntry/> should render 1`] = `
<div>
<div
class="mx_InteractiveAuthEntryComponents_emailWrapper"
>
<p>
<span>
To create your account, open the link in the email we just sent to
<b>
[email protected]
</b>
.
</span>
</p>
<p
class="secondary"
>
<span>
Did not receive it?
<div
aria-label="Resend"
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link_inline"
role="button"
tabindex="0"
>
Resend it
</div>
</span>
</p>
</div>
</div>
`;
Loading