Skip to content

Commit 07dc8d8

Browse files
authored
fix: escape CSS selector keys to handle special characters (anomalyco#9030)
1 parent d377246 commit 07dc8d8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/ui/src/components/list.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function List<T>(props: ListProps<T> & { ref?: (ref: ListRef) => void })
6969
if (!props.current) return
7070
const key = props.key(props.current)
7171
requestAnimationFrame(() => {
72-
const element = scrollRef()?.querySelector(`[data-key="${key}"]`)
72+
const element = scrollRef()?.querySelector(`[data-key="${CSS.escape(key)}"]`)
7373
element?.scrollIntoView({ block: "center" })
7474
})
7575
})
@@ -81,7 +81,7 @@ export function List<T>(props: ListProps<T> & { ref?: (ref: ListRef) => void })
8181
scrollRef()?.scrollTo(0, 0)
8282
return
8383
}
84-
const element = scrollRef()?.querySelector(`[data-key="${active()}"]`)
84+
const element = scrollRef()?.querySelector(`[data-key="${CSS.escape(active()!)}"]`)
8585
element?.scrollIntoView({ block: "center" })
8686
})
8787

0 commit comments

Comments
 (0)