Skip to content

Commit

Permalink
TapArea: support to new dataTestId prop (#3179)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertCarreras authored Aug 31, 2023
1 parent b38024b commit c67d15c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
8 changes: 8 additions & 0 deletions docs/pages/web/taparea.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
32 changes: 19 additions & 13 deletions packages/gestalt/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -1642,7 +1647,7 @@ interface SideNavigationTopItemProps {
notificationAccessibilityLabel?: string | undefined;
onClick?: ButtonEventHandlerType | undefined;
primaryAction?: PrimaryActionType | undefined;
ref?: HTMLLIElement,
ref?: HTMLLIElement;
}

interface SideNavigationNestedItemProps {
Expand All @@ -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 {
Expand Down Expand Up @@ -1898,6 +1903,7 @@ interface TagDataProps {
interface CommonTapAreaProps {
accessibilityLabel?: string | undefined;
children: Node;
dataTestId?: string;
disabled?: boolean | undefined;
fullHeight?: boolean | undefined;
fullWidth?: boolean | undefined;
Expand Down Expand Up @@ -2611,29 +2617,29 @@ export interface TableSubComponents {
*/
export const Table: React.FunctionComponent<TableProps> & 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<React.PropsWithChildren<TableOfContentsItemProps>>;
}

export const TableOfContents: React.FunctionComponent<TableOfContentsProps> & TableOfContentsSubComponents;
export const TableOfContents: React.FunctionComponent<TableOfContentsProps> &
TableOfContentsSubComponents;

/**
* https://gestalt.pinterest.systems/web/tabs
Expand Down
4 changes: 4 additions & 0 deletions packages/gestalt/src/TapArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type OnTapType = ({|
type BaseTapArea = {|
accessibilityLabel?: string,
children?: Node,
dataTestId?: string,
disabled?: boolean,
fullHeight?: boolean,
fullWidth?: boolean,
Expand Down Expand Up @@ -88,6 +89,7 @@ const TapAreaWithForwardRef: AbstractComponent<unionProps, unionRefs> = forwardR
const {
accessibilityLabel,
children,
dataTestId,
disabled = false,
fullHeight,
fullWidth = true,
Expand Down Expand Up @@ -236,6 +238,7 @@ const TapAreaWithForwardRef: AbstractComponent<unionProps, unionRefs> = forwardR
<InternalLink
accessibilityCurrent={accessibilityCurrent}
accessibilityLabel={ariaLabel}
dataTestId={dataTestId}
disabled={disabled}
href={href}
fullHeight={fullHeight}
Expand Down Expand Up @@ -278,6 +281,7 @@ const TapAreaWithForwardRef: AbstractComponent<unionProps, unionRefs> = forwardR
aria-expanded={accessibilityExpanded}
aria-haspopup={accessibilityHaspopup}
aria-label={accessibilityLabel}
data-test-id={dataTestId}
className={buttonRoleClasses}
onClick={handleClick}
onBlur={(event) => {
Expand Down

0 comments on commit c67d15c

Please sign in to comment.