-
Notifications
You must be signed in to change notification settings - Fork 273
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
fix(anchor): [anchor] fixed the bug that querySelect cannot select sp… #2620
Conversation
WalkthroughThe pull request includes an update to the version number of the Changes
Possibly related PRs
Suggested labels
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
packages/renderless/src/anchor/index.ts (1)
Line range hint
208-211
: Enhance documentation and test coverage for horizontal scrolling fixThe comment about fixing horizontal anchor scrolling could be more descriptive. Additionally, we should ensure this fix is properly tested.
Consider improving the comment to better explain the issue and solution:
- props.offsetTop // 修复横向锚点无法滚动到顶部 + props.offsetTop // Subtracts offsetTop to ensure proper alignment when scrolling to anchors in horizontal layoutsWould you like me to help create test cases for horizontal scrolling scenarios? This could include:
- Testing with different offsetTop values
- Verifying scroll behavior with horizontal layouts
- Checking alignment precision in various container sizes
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
packages/renderless/package.json
(1 hunks)packages/renderless/src/anchor/index.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/renderless/package.json
🔇 Additional comments (1)
packages/renderless/src/anchor/index.ts (1)
15-17
: Consider improving the element selection logic
While the fix correctly handles ID-based selection, there are a few potential improvements to consider:
- The function assumes the parent parameter is needed for non-ID selectors, but it might be redundant when using document-wide selectors.
- The optional chaining is only applied to the selector parameter, but not to the subsequent operations.
Consider this more robust implementation:
-const getEleMentBySelect = (parent, selector) =>
- selector?.startsWith('#') ? document.getElementById(selector.slice(1)) : parent.querySelector(selector)
+const getEleMentBySelect = (parent, selector) => {
+ if (!selector) return null;
+ return selector.startsWith('#')
+ ? document.getElementById(selector.slice(1))
+ : (parent || document).querySelector(selector);
+}
Let's verify the usage patterns of this function:
…ecial id
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
@opentiny/vue-renderless
package to 3.20.3.Bug Fixes
#
.