Skip to content

Commit acaa612

Browse files
authored
Merge pull request #838 from gabrieljablonski/fix-query-selector
Fix anchor element selector to support usage of `React.useId()`
2 parents 129f3f0 + dd626ed commit acaa612

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/components/Tooltip/Tooltip.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const Tooltip = ({
107107
const debouncedHandleHideTooltip = debounce(handleHideTooltip, 50)
108108

109109
useEffect(() => {
110-
const elementReference = document.querySelector(`#${anchorId}`)
110+
const elementReference = document.querySelector(`[id='${anchorId}']`)
111111

112112
if (!elementReference) {
113113
// eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -141,7 +141,7 @@ const Tooltip = ({
141141
}, [anchorId, events, delayHide, delayShow])
142142

143143
useEffect(() => {
144-
const elementReference = document.querySelector(`#${anchorId}`)
144+
const elementReference = document.querySelector(`[id='${anchorId}']`)
145145

146146
computeToolTipPosition({
147147
place,

src/components/TooltipController/TooltipController.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const TooltipController = ({
130130
return () => {}
131131
}
132132

133-
const elementReference = document.querySelector(`#${anchorId}`)
133+
const elementReference = document.querySelector(`[id='${anchorId}']`)
134134

135135
if (!elementReference) {
136136
// eslint-disable-next-line @typescript-eslint/no-empty-function

0 commit comments

Comments
 (0)