From c67d15c4a4355cdf080463a56d1d81f738a2d244 Mon Sep 17 00:00:00 2001 From: Alberto Carreras <10593890+AlbertCarreras@users.noreply.github.com> Date: Thu, 31 Aug 2023 18:10:04 +0200 Subject: [PATCH] TapArea: support to new `dataTestId` prop (#3179) --- docs/pages/web/taparea.js | 8 ++++++++ packages/gestalt/dist/index.d.ts | 32 +++++++++++++++++++------------- packages/gestalt/src/TapArea.js | 4 ++++ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/docs/pages/web/taparea.js b/docs/pages/web/taparea.js index 35221cf847..a42e20d53c 100644 --- a/docs/pages/web/taparea.js +++ b/docs/pages/web/taparea.js @@ -82,6 +82,14 @@ export default function DocsPage({ generatedDocGen }: {| generatedDocGen: DocGen 'TapArea is a wrapper around non-button components (or children) that provides clicking / touching functionality as if they were a unified button area.', href: 'basic-taparea', }, + { + name: 'dataTestId', + type: 'string', + required: false, + description: [ + 'Available for testing purposes, if needed. Consider [better queries](https://testing-library.com/docs/queries/about/#priority) before using this prop.', + ], + }, { name: 'disabled', type: 'boolean', diff --git a/packages/gestalt/dist/index.d.ts b/packages/gestalt/dist/index.d.ts index 829d8c0795..2f4eb7a2b3 100644 --- a/packages/gestalt/dist/index.d.ts +++ b/packages/gestalt/dist/index.d.ts @@ -1339,7 +1339,12 @@ interface OverlayPanelDismissingElementProps { interface PageHeaderAction { component: | React.ReactElement< - typeof Button | typeof ButtonLink | typeof IconButton | typeof Link | typeof Tooltip | typeof Text + | typeof Button + | typeof ButtonLink + | typeof IconButton + | typeof Link + | typeof Tooltip + | typeof Text > | undefined; dropdownItems: @@ -1642,7 +1647,7 @@ interface SideNavigationTopItemProps { notificationAccessibilityLabel?: string | undefined; onClick?: ButtonEventHandlerType | undefined; primaryAction?: PrimaryActionType | undefined; - ref?: HTMLLIElement, + ref?: HTMLLIElement; } interface SideNavigationNestedItemProps { @@ -1651,7 +1656,7 @@ interface SideNavigationNestedItemProps { active?: 'page' | 'section' | undefined; counter?: { number: string; accessibilityLabel: string } | undefined; onClick?: ButtonEventHandlerType | undefined; - ref?: HTMLLIElement, + ref?: HTMLLIElement; } interface SideNavigationGroupProps { @@ -1898,6 +1903,7 @@ interface TagDataProps { interface CommonTapAreaProps { accessibilityLabel?: string | undefined; children: Node; + dataTestId?: string; disabled?: boolean | undefined; fullHeight?: boolean | undefined; fullWidth?: boolean | undefined; @@ -2611,29 +2617,29 @@ export interface TableSubComponents { */ export const Table: React.FunctionComponent & TableSubComponents; - interface TableOfContentsItemProps { - label: string, - href: string, - active?: boolean, - onClick?: TapAreaEventHandlerType, - children?: Node, + label: string; + href: string; + active?: boolean; + onClick?: TapAreaEventHandlerType; + children?: Node; } /** * https://gestalt.pinterest.systems/web/tableofcontents */ export interface TableOfContentsProps { - accessibilityLabel?: string, - title?: string, - children: Node + accessibilityLabel?: string; + title?: string; + children: Node; } export interface TableOfContentsSubComponents { Item: React.FunctionComponent>; } -export const TableOfContents: React.FunctionComponent & TableOfContentsSubComponents; +export const TableOfContents: React.FunctionComponent & + TableOfContentsSubComponents; /** * https://gestalt.pinterest.systems/web/tabs diff --git a/packages/gestalt/src/TapArea.js b/packages/gestalt/src/TapArea.js index 662a2585fa..fa89293965 100644 --- a/packages/gestalt/src/TapArea.js +++ b/packages/gestalt/src/TapArea.js @@ -36,6 +36,7 @@ export type OnTapType = ({| type BaseTapArea = {| accessibilityLabel?: string, children?: Node, + dataTestId?: string, disabled?: boolean, fullHeight?: boolean, fullWidth?: boolean, @@ -88,6 +89,7 @@ const TapAreaWithForwardRef: AbstractComponent = forwardR const { accessibilityLabel, children, + dataTestId, disabled = false, fullHeight, fullWidth = true, @@ -236,6 +238,7 @@ const TapAreaWithForwardRef: AbstractComponent = forwardR = forwardR aria-expanded={accessibilityExpanded} aria-haspopup={accessibilityHaspopup} aria-label={accessibilityLabel} + data-test-id={dataTestId} className={buttonRoleClasses} onClick={handleClick} onBlur={(event) => {