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

docs: fix back to top does not work and the document tab title does n… #2712

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

gimmyhehe
Copy link
Member

@gimmyhehe gimmyhehe commented Dec 28, 2024

…ot sticky after the layout is modified

PR

修复布局修改后,返回顶部不生效以及文档页签标题未吸顶问题
image

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Bug Fixes

    • Corrected a typo in the doc-layout-scroller element ID across multiple components
    • Updated scroll-related methods to reference the correct DOM element
    • Improved scroll positioning and back-to-top functionality
  • Style

    • Modified margin-top styling for the .docs-content class
    • Adjusted layout and positioning of components

Copy link

coderabbitai bot commented Dec 28, 2024

Walkthrough

The pull request focuses on correcting and improving the scrolling behavior and layout in Vue components. The main changes involve fixing a typographical error in the doc-layout-scroller element ID, updating scroll-related functions to reference the correct element, and making minor style adjustments. These modifications ensure consistent element referencing and improve the overall component structure without significantly altering the core logic.

Changes

File Change Summary
examples/sites/src/views/components/components.vue - Corrected element ID from doc-layout-scoller to doc-layout-scroller
- Replaced padding with margin-top for .docs-content class
- Added offset-top property to tiny-anchor component
examples/sites/src/views/components/float-settings.vue - Updated onBackTop method to use doc-layout-scroller
- Modified scroll listener functions to reference new element
- Adjusted scroll position tracking and back-to-top button visibility

Sequence Diagram

sequenceDiagram
    participant User
    participant Component
    participant ScrollElement
    
    User->>Component: Interact with page
    Component->>ScrollElement: Set scroll listener
    ScrollElement-->>Component: Track scroll position
    Component->>Component: Update back-to-top button visibility
    User->>Component: Click back-to-top
    Component->>ScrollElement: Scroll to top
Loading

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • zzcr

Poem

🐰 Scrolling rabbit hops with glee,
Through components, bug-free and free!
IDs corrected, margins aligned,
A coding dance, perfectly designed.
Hop, hop, hooray! The scroll works right! 🚀


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the documentation 对文档的改进或补充 label Dec 28, 2024
Copy link

Walkthrough

此PR修复了在布局修改后,返回顶部功能失效以及文档页签标题未吸顶的问题。主要通过修正元素ID和调整CSS样式来实现。

Changes

文件 概要
examples/sites/src/views/components/components.vue 修正了元素ID的拼写错误,并调整了CSS样式以确保文档页签标题吸顶。
examples/sites/src/views/components/float-settings.vue 修正了元素ID的拼写错误,确保返回顶部功能正常工作。

document.getElementById('doc-layout-scoller').scrollTo({
top: scrollTarget.offsetTop + 52,
document.getElementById('doc-layout-scroller').scrollTo({
top: scrollTarget.offsetTop,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of + 52 from scrollTarget.offsetTop may affect the scroll position. Ensure that this change does not negatively impact the intended scroll behavior.

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Walkthrough

This PR fixes the problem that after the layout is modified, the return to top function fails and the document tab title does not move to the top. This is mainly achieved by correcting element IDs and adjusting CSS styles.

Changes

Documentation Summary
examples/sites/src/views/components/components.vue Fixed the spelling error of element ID, and adjusted the CSS style to ensure that the document label title is at the top.
examples/sites/src/views/components/float-settings.vue Fixed typo of element ID to ensure return to top functionality works properly.

Copy link

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (4)
examples/sites/src/views/components/components.vue (4)

236-236: Check if offset-top of 56 is suitable
You hard-coded :offset-top="56". Consider a dynamic approach if the header height is not always 56px.


488-489: Use smooth scrolling for hash navigation
Using scrollTarget.offsetTop and behavior: 'smooth' is user-friendly. Consider a fallback if older browsers need support.


503-503: Repeated scroll to top call
Same approach as line 473. If more lines repeat this pattern, consider extracting a helper function for maintainability.


806-806: Switched from padding-top to margin-top
Altering the layout from padding to margin can affect container positioning. Verify that it doesn’t unintentionally break existing CSS flows.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0fb1f3 and 7415155.

📒 Files selected for processing (2)
  • examples/sites/src/views/components/components.vue (8 hunks)
  • examples/sites/src/views/components/float-settings.vue (3 hunks)
🔇 Additional comments (11)
examples/sites/src/views/components/float-settings.vue (3)

152-152: Good job referencing the correct element for smooth scrolling.
You’ve correctly updated the target element ID and used the behavior: 'smooth' option. Note that not all legacy browsers support smooth scrolling by default.


199-199: Verify docLayout not null before assigning
You are already checking if (docLayout) before assigning the scroll handler. This ensures no runtime errors if the element is not found.


221-221: Ensure consistent cleanup of the scroll listener
Reassigning onscroll to null is okay, but confirm that other potential listeners or references are not left dangling if multiple assignments exist. If only this assignment is used, this is fine.

examples/sites/src/views/components/components.vue (8)

19-19: Corrected element ID for the scroller container
Changing the ID to doc-layout-scroller aligns with references in related files and ensures a uniform approach to scrolling logic.


241-241: Consistent container-id usage
Pointing container-id="#doc-layout-scroller" matches the layout changes, ensuring the anchor scrolls within the intended container.


473-473: Smoothly scroll to top
This logic mirrors the fix in float-settings.vue. Good consistency in referencing doc-layout-scroller.


486-486: Skip scroll when running tests
Your condition checks !isRunningTest before scrolling. This should help keep automated tests stable.


624-629: Runtime checks for null
You reference docLayout and derive layout measurements before checking. Ensure docLayout is not null to avoid potential errors on edge cases.


635-635: Add event listener to doc-layout-scroller
This matches the usage in float-settings.vue. Good job unifying the scroll event element.


643-643: Remove event listener on unmount
Cleanly removing the scroll event in onUnmounted is a best practice, preventing memory leaks.


830-830: Sticky tab header
Setting top: 0 ensures the header remains in view. Confirm that overlapping elements at higher z-indices do not interfere with the sticky header.

@kagol kagol merged commit 5b8edfe into dev Dec 30, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 对文档的改进或补充
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants