From 264e202ccd99c1f5b2ea8b7367131a8124b362ce Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Fri, 26 Apr 2024 11:10:15 +0200 Subject: [PATCH] Add extra attribute to `AccessibleButton` (#12456) * Update snapshots * Add extra attribute to `AccessibleButton` --- .../views/elements/AccessibleButton.tsx | 22 +++++++++++++-- .../CurrentDeviceSection-test.tsx.snap | 28 ++++++++----------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/components/views/elements/AccessibleButton.tsx b/src/components/views/elements/AccessibleButton.tsx index 26b4390e56..05b844284a 100644 --- a/src/components/views/elements/AccessibleButton.tsx +++ b/src/components/views/elements/AccessibleButton.tsx @@ -14,7 +14,7 @@ limitations under the License. */ -import React, { forwardRef, FunctionComponent, HTMLAttributes, InputHTMLAttributes, Ref } from "react"; +import React, { ComponentProps, forwardRef, FunctionComponent, HTMLAttributes, InputHTMLAttributes, Ref } from "react"; import classnames from "classnames"; import { Tooltip } from "@vector-im/compound-web"; @@ -61,6 +61,8 @@ type DynamicElementProps = Partial< > & Omit, "onClick">; +type TooltipProps = ComponentProps; + /** * Type of props accepted by {@link AccessibleButton}. * @@ -96,6 +98,14 @@ type Props = DynamicHtmlElementProps & * Only valid when used in conjunction with `title`. */ caption?: string; + /** + * The placement of the tooltip. + */ + placement?: TooltipProps["placement"]; + /** + * Callback for when the tooltip is opened or closed. + */ + onTooltipOpenChange?: TooltipProps["onOpenChange"]; }; /** @@ -128,6 +138,8 @@ const AccessibleButton = forwardRef(function , ref: Ref, @@ -199,7 +211,13 @@ const AccessibleButton = forwardRef(function + {button} ); diff --git a/test/components/views/settings/devices/__snapshots__/CurrentDeviceSection-test.tsx.snap b/test/components/views/settings/devices/__snapshots__/CurrentDeviceSection-test.tsx.snap index 2cd642eac9..bd3ec55ca6 100644 --- a/test/components/views/settings/devices/__snapshots__/CurrentDeviceSection-test.tsx.snap +++ b/test/components/views/settings/devices/__snapshots__/CurrentDeviceSection-test.tsx.snap @@ -135,26 +135,22 @@ exports[` handles when device is falsy 1`] = ` > Current session -