fix: escape CSS selector keys to handle special characters (#9030)

pull/5339/head
Slone 2026-01-17 19:48:38 +08:00 committed by GitHub
parent d377246491
commit 07dc8d8ce4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -69,7 +69,7 @@ export function List<T>(props: ListProps<T> & { ref?: (ref: ListRef) => void })
if (!props.current) return
const key = props.key(props.current)
requestAnimationFrame(() => {
const element = scrollRef()?.querySelector(`[data-key="${key}"]`)
const element = scrollRef()?.querySelector(`[data-key="${CSS.escape(key)}"]`)
element?.scrollIntoView({ block: "center" })
})
})
@ -81,7 +81,7 @@ export function List<T>(props: ListProps<T> & { ref?: (ref: ListRef) => void })
scrollRef()?.scrollTo(0, 0)
return
}
const element = scrollRef()?.querySelector(`[data-key="${active()}"]`)
const element = scrollRef()?.querySelector(`[data-key="${CSS.escape(active()!)}"]`)
element?.scrollIntoView({ block: "center" })
})