Skip to content

Commit

Permalink
fix: escape single quotes from data-tooltip-id selector
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieljablonski committed Apr 28, 2024
1 parent c7f865f commit ab0f163
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ const Tooltip = ({
useEffect(() => {
let selector = imperativeOptions?.anchorSelect ?? anchorSelect ?? ''
if (!selector && id) {
selector = `[data-tooltip-id='${id}']`
selector = `[data-tooltip-id='${id.replace(/'/g, "\\'")}']`
}
const documentObserverCallback: MutationCallback = (mutationList) => {
const newAnchors: HTMLElement[] = []
Expand Down Expand Up @@ -798,7 +798,7 @@ const Tooltip = ({
useEffect(() => {
let selector = imperativeOptions?.anchorSelect ?? anchorSelect
if (!selector && id) {
selector = `[data-tooltip-id='${id}']`
selector = `[data-tooltip-id='${id.replace(/'/g, "\\'")}']`
}
if (!selector) {
return
Expand Down
2 changes: 1 addition & 1 deletion src/components/TooltipController/TooltipController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(

let selector = anchorSelect
if (!selector && id) {
selector = `[data-tooltip-id='${id}']`
selector = `[data-tooltip-id='${id.replace(/'/g, "\\'")}']`
}
if (selector) {
try {
Expand Down

0 comments on commit ab0f163

Please sign in to comment.