Skip to content

Commit c208987

Browse files
committed
Add cleanup function
1 parent 37cab51 commit c208987

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/components/Tooltip/Tooltip.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ const Tooltip = ({
233233
} else {
234234
removeAriaDescribedBy(activeAnchor)
235235
}
236+
237+
// eslint-disable-next-line consistent-return
238+
return () => {
239+
// cleanup aria-describedby when the tooltip is closed
240+
removeAriaDescribedBy(activeAnchor)
241+
removeAriaDescribedBy(previousActiveAnchor)
242+
}
236243
}, [activeAnchor, show, id, previousActiveAnchor])
237244

238245
/**

0 commit comments

Comments
 (0)