-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Labels
type: bugSomething isn't working like it's supposed toSomething isn't working like it's supposed to
Description
ReactUSWDS Version & USWDS Version:
Describe the bug
The title prop is not being pass down to the tool tip button. In your types you define title as a prop that can be passed as seen here
type TooltipProps<T> = {
label: ReactNode
title?: string
position?: 'top' | 'bottom' | 'left' | 'right' | undefined
wrapperclasses?: string
className?: string
children: ReactNode
} &
however in reviewing the code i see that title is alway set with an empty string. As seen here
return (
// the span that wraps the element will have the tooltip class
<span data-testid="tooltipWrapper" className={wrapperClasses}>
<button
{...remainingProps}
data-testid="triggerElement"
ref={triggerElementRef}
aria-describedby={tooltipID}
tabIndex={0}
type="button"
className={triggerClasses}
title=""
onMouseEnter={showTooltip}
onMouseOver={showTooltip}
onFocus={showTooltip}
onMouseLeave={hideTooltip}
onBlur={hideTooltip}
onKeyDown={hideTooltip}>
{children}
</button>
<span
data-testid="tooltipBody"
title={title ?? (typeof label === 'string' ? label : undefined)}
id={tooltipID}
ref={tooltipBodyRef}
className={tooltipBodyClasses}
role="tooltip"
aria-hidden={!isVisible}
style={positionStyles}>
{label}
</span>
</span>
)
To Reproduce
Steps to reproduce the behavior:
- Create a tool tip
- pass title prop on tool tip something like this
<div className="margin-4">
<Tooltip label="Default" title="test">Default</Tooltip>
</div>
- inspect element to see the title on the button
- it will show a blank title value
title=""
Expected behavior
The title prop should be pass to the button element and readable by screen readers.
Device and Browser Information (please complete the following information if describing a UI bug):
All browser all versions
Metadata
Metadata
Assignees
Labels
type: bugSomething isn't working like it's supposed toSomething isn't working like it's supposed to