Repository navigation
fix: avoid querySelector SyntaxError when option value contains special characters - #674
mokshupadhyay wants to merge 1 commit into
Conversation
|
@mokshupadhyay is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. Walkthrough活动选项滚动逻辑改为按 Changes活动选项滚动
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk:
|
|
Hi @yoyo837, a friendly ping: this is ready for review whenever you have time. Happy to adjust anything. Thanks! |
When the user moves the active option with the keyboard,
RawOptionListscrolls the active cell of each column into view by looking up itsliwithquerySelector('li[data-path-key="..."]'). The path key goes into a CSS attribute selector after escaping only the double quotes, so an option value with a backslash or a newline makes an invalid selector and the whole component throws:A value such as a Windows path (
C:\) is a plausible case.The effect now collects the
li[data-path-key]elements once and finds the active one by comparing thedata-path-keyattribute to the key, so no selector has to be built from option values and no escaping is needed.Test:
should not crash when scrolling active option with backslash or newline in valueopens a cascader with optionsC:\,a\"bandline1\nline2, moves the active option with ArrowDown and checks that each one becomes the active item and is scrolled into view. It fails onmasterwith theSyntaxErrorabove and passes now.npm test(12 suites, 129 passed, 2 skipped as before),npm run tscandnpm run lint(0 errors) pass.Summary by CodeRabbit