Skip to content

Commit

Permalink
feat(TooltipPrimitive): add ariaLabel, ariaLabelledby props
Browse files Browse the repository at this point in the history
  • Loading branch information
sarkaaa committed Nov 11, 2024
1 parent 6c33de5 commit 6b3bf9d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,23 @@ const meta: Meta<typeof TooltipPrimitive> = {

parameters: {
controls: {
exclude: ["onShow", "enabled", "tabIndex", "renderInPortal", "size", "stopPropagation"],
exclude: [
"onShow",
"enabled",
"tabIndex",
"renderInPortal",
"size",
"stopPropagation",
"ariaLabel",
"ariaLabelledby",
],
},
},

args: {
onShow: action("onShow"),
ariaLabel: "Tooltip label",
ariaLabelledby: "Tooltip labelledby",
},
};

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

0 comments on commit 6b3bf9d

Please sign in to comment.