File tree 1 file changed +6
-1
lines changed
packages/coreui-react/src/components/tooltip
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -90,9 +90,10 @@ export const CTooltip = forwardRef<HTMLDivElement, CTooltipProps>(
90
90
} ,
91
91
ref ,
92
92
) => {
93
- const tooltipRef = useRef ( null )
93
+ const tooltipRef = useRef < HTMLDivElement > ( null )
94
94
const togglerRef = useRef ( null )
95
95
const forkedRef = useForkedRef ( ref , tooltipRef )
96
+ const uID = useRef ( `tooltip${ Math . floor ( Math . random ( ) * 1_000_000 ) } ` )
96
97
97
98
const { initPopper, destroyPopper } = usePopper ( )
98
99
const [ _visible , setVisible ] = useState ( visible )
@@ -149,6 +150,9 @@ export const CTooltip = forwardRef<HTMLDivElement, CTooltipProps>(
149
150
return (
150
151
< >
151
152
{ React . cloneElement ( children as React . ReactElement < any > , {
153
+ ...( _visible && {
154
+ 'aria-describedby' : uID . current ,
155
+ } ) ,
152
156
ref : togglerRef ,
153
157
...( ( trigger === 'click' || trigger . includes ( 'click' ) ) && {
154
158
onClick : ( ) => toggleVisible ( ! _visible ) ,
@@ -188,6 +192,7 @@ export const CTooltip = forwardRef<HTMLDivElement, CTooltipProps>(
188
192
} ,
189
193
className ,
190
194
) }
195
+ id = { uID . current }
191
196
ref = { forkedRef }
192
197
role = "tooltip"
193
198
{ ...rest }
You can’t perform that action at this time.
0 commit comments