Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape single quotes from data-tooltip-id selector #1187

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading