@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import React , { ReactElement , useState } from "react" ;
17+ import React , { ReactElement , useRef , useState } from "react" ;
1818import classNames from "classnames" ;
1919import { Room } from "matrix-js-sdk/src/models/room" ;
2020import { RoomMember } from "matrix-js-sdk/src/matrix" ;
@@ -89,6 +89,7 @@ export interface PillProps {
8989}
9090
9191export const Pill : React . FC < PillProps > = ( { type : propType , url, inMessage, room, shouldShowPillAvatar = true } ) => {
92+ const tooltipId = useRef ( `mx_Pill_${ Math . random ( ) } ` ) . current ;
9293 const [ hover , setHover ] = useState ( false ) ;
9394 const { event, member, onClick, resourceId, targetRoom, text, type } = usePermalink ( {
9495 room,
@@ -117,7 +118,7 @@ export const Pill: React.FC<PillProps> = ({ type: propType, url, inMessage, room
117118 setHover ( false ) ;
118119 } ;
119120
120- const tip = hover && resourceId ? < Tooltip label = { resourceId } alignment = { Alignment . Right } /> : null ;
121+ const tip = hover && resourceId ? < Tooltip id = { tooltipId } label = { resourceId } alignment = { Alignment . Right } /> : null ;
121122 let avatar : ReactElement | null = null ;
122123 let pillText : string | null = text ;
123124
@@ -165,13 +166,19 @@ export const Pill: React.FC<PillProps> = ({ type: propType, url, inMessage, room
165166 onClick = { onClick }
166167 onMouseOver = { onMouseOver }
167168 onMouseLeave = { onMouseLeave }
169+ aria-describedby = { tooltipId }
168170 >
169171 { avatar }
170172 < span className = "mx_Pill_text" > { pillText } </ span >
171173 { tip }
172174 </ a >
173175 ) : (
174- < span className = { classes } onMouseOver = { onMouseOver } onMouseLeave = { onMouseLeave } >
176+ < span
177+ className = { classes }
178+ onMouseOver = { onMouseOver }
179+ onMouseLeave = { onMouseLeave }
180+ aria-describedby = { tooltipId }
181+ >
175182 { avatar }
176183 < span className = "mx_Pill_text" > { pillText } </ span >
177184 { tip }
0 commit comments