Skip to content

Commit

Permalink
feat(TooltipPrimitive): add aria-label prop
Browse files Browse the repository at this point in the history
  • Loading branch information
sarkaaa committed Nov 14, 2024
1 parent 73ad1bf commit 3eafc13
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,21 @@ const meta: Meta<typeof TooltipPrimitive> = {

parameters: {
controls: {
exclude: ["onShow", "enabled", "tabIndex", "renderInPortal", "size", "stopPropagation"],
exclude: [
"onShow",
"enabled",
"tabIndex",
"renderInPortal",
"size",
"stopPropagation",
"aria-label",
],
},
},

args: {
onShow: action("onShow"),
"aria-label": "Tooltip label",
},
};

Expand All @@ -59,6 +68,7 @@ export const Default: Story = {
"size",
"stopPropagation",
"block",
"aria-label",
],
},
},
Expand Down Expand Up @@ -162,6 +172,7 @@ export const WithImageInside: Story = {
"renderInPortal",
"stopPropagation",
"block",
"aria-label",
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const TooltipPrimitive = ({
placement,
noFlip,
offset,
"aria-label": ariaLabel,
}: Props) => {
const [shown, setShown] = React.useState(false);
const [referenceElement, setReferenceElement] = React.useState<HTMLSpanElement | null>(null);
Expand Down Expand Up @@ -133,6 +134,7 @@ const TooltipPrimitive = ({
enabled={enabled}
removeUnderlinedText={removeUnderlinedText}
block={block}
aria-label={ariaLabel}
>
{children}
</TooltipWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ export interface Props extends Common.Globals {
readonly placement?: Placement;
readonly noFlip?: boolean;
readonly offset?: [number, number];
readonly "aria-label"?: string;
}

0 comments on commit 3eafc13

Please sign in to comment.