Skip to content

Commit 356de4d

Browse files
Moved the described by to the tooltip trigger instead of the wrapped when disabled
1 parent 3283e9f commit 356de4d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/react-components/src/tooltip/src/TooltipTrigger.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,20 @@ export function InnerTooltipTrigger({
153153

154154
const tooltipId = useId(tooltip.props.id, "o-ui-tooltip");
155155

156+
const triggerWithDescribedBy = augmentElement(trigger, {
157+
"aria-describedby": isOpen ? tooltipId : undefined
158+
});
159+
156160
// HACK: a disabled element doesn't fire event, therefore the element is wrapped in a div.
157-
const triggerElement = !trigger.props.disabled ? trigger : (
161+
const triggerElement = !triggerWithDescribedBy.props.disabled ? triggerWithDescribedBy : (
158162
<div className="o-ui-tooltip-disabled-wrapper">
159-
{trigger}
163+
{triggerWithDescribedBy}
160164
</div>
161165
);
162166

163-
// TODO: move aria-describedby on the button when there is a wrapper?
164167
const triggerMarkup = augmentElement(triggerElement, mergeProps(
165168
triggerProps,
166169
{
167-
"aria-describedby": isOpen ? tooltipId : undefined,
168170
ref: triggerRef
169171
}
170172
));

0 commit comments

Comments
 (0)