Skip to content

Commit ab0f163

Browse files
fix: escape single quotes from data-tooltip-id selector
1 parent c7f865f commit ab0f163

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Diff for: src/components/Tooltip/Tooltip.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ const Tooltip = ({
646646
useEffect(() => {
647647
let selector = imperativeOptions?.anchorSelect ?? anchorSelect ?? ''
648648
if (!selector && id) {
649-
selector = `[data-tooltip-id='${id}']`
649+
selector = `[data-tooltip-id='${id.replace(/'/g, "\\'")}']`
650650
}
651651
const documentObserverCallback: MutationCallback = (mutationList) => {
652652
const newAnchors: HTMLElement[] = []
@@ -798,7 +798,7 @@ const Tooltip = ({
798798
useEffect(() => {
799799
let selector = imperativeOptions?.anchorSelect ?? anchorSelect
800800
if (!selector && id) {
801-
selector = `[data-tooltip-id='${id}']`
801+
selector = `[data-tooltip-id='${id.replace(/'/g, "\\'")}']`
802802
}
803803
if (!selector) {
804804
return

Diff for: src/components/TooltipController/TooltipController.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(
220220

221221
let selector = anchorSelect
222222
if (!selector && id) {
223-
selector = `[data-tooltip-id='${id}']`
223+
selector = `[data-tooltip-id='${id.replace(/'/g, "\\'")}']`
224224
}
225225
if (selector) {
226226
try {

0 commit comments

Comments
 (0)