File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
packages/coreui-react/src/components/tooltip Expand file tree Collapse file tree 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>(
9090 } ,
9191 ref ,
9292 ) => {
93- const tooltipRef = useRef ( null )
93+ const tooltipRef = useRef < HTMLDivElement > ( null )
9494 const togglerRef = useRef ( null )
9595 const forkedRef = useForkedRef ( ref , tooltipRef )
96+ const uID = useRef ( `tooltip${ Math . floor ( Math . random ( ) * 1_000_000 ) } ` )
9697
9798 const { initPopper, destroyPopper } = usePopper ( )
9899 const [ _visible , setVisible ] = useState ( visible )
@@ -149,6 +150,9 @@ export const CTooltip = forwardRef<HTMLDivElement, CTooltipProps>(
149150 return (
150151 < >
151152 { React . cloneElement ( children as React . ReactElement < any > , {
153+ ...( _visible && {
154+ 'aria-describedby' : uID . current ,
155+ } ) ,
152156 ref : togglerRef ,
153157 ...( ( trigger === 'click' || trigger . includes ( 'click' ) ) && {
154158 onClick : ( ) => toggleVisible ( ! _visible ) ,
@@ -188,6 +192,7 @@ export const CTooltip = forwardRef<HTMLDivElement, CTooltipProps>(
188192 } ,
189193 className ,
190194 ) }
195+ id = { uID . current }
191196 ref = { forkedRef }
192197 role = "tooltip"
193198 { ...rest }
You can’t perform that action at this time.
0 commit comments