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

Add store scroll feature to BitAppShell (#10233) #10234

Merged

Conversation

msynk
Copy link
Member

@msynk msynk commented Mar 13, 2025

closes #10233

Summary by CodeRabbit

  • New Features
    • Enhanced scroll management now preserves your scroll position when navigating or refreshing pages, ensuring a smoother and more consistent browsing experience.

Copy link

coderabbitai bot commented Mar 13, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes add a mechanism to manage scroll positions using session storage. A new static property STORE_KEY is introduced to hold session storage keys, and the new storeScroll method centralizes the scroll position logic. Methods such as initScroll, afterRenderScroll, and onScroll have been modified to interact with the session storage via the storeScroll method, ensuring the correct scroll positions are restored and updated consistently.

Changes

File Summary
src/BlazorUI/.../BitAppShell.ts Added static property STORE_KEY; introduced storeScroll method; updated initScroll, afterRenderScroll, and onScroll methods to use it.

Sequence Diagram(s)

sequenceDiagram
    participant UI as UI Component
    participant AS as AppShell
    participant SS as Session Storage

    UI->>AS: onScroll(event)
    AS->>AS: storeScroll(url, scrollValue)
    AS->>SS: Save updated scroll position

    Note over AS,SS: Scroll state stored in session

    UI->>AS: initScroll(url)
    AS->>SS: Retrieve stored scroll position
    SS-->>AS: Return scroll position
    AS->>UI: Apply scroll position

    UI->>AS: afterRenderScroll()
    AS->>AS: storeScroll(url, updatedValue)
    AS->>SS: Update stored scroll position
Loading

Poem

I'm a little rabbit, hopping with delight,
My scrolls now saved in session, out of sight!
With a shiny STORE_KEY lighting up the code,
Every scroll and jump is perfectly bestowed.
A merry dance of bytes, a code bunny's cheer—
Celebrating changes that make navigation clear!
🐰💻


🪧 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.
  • @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.

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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between af8bb32 and 6723b0c.

📒 Files selected for processing (1)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/AppShell/BitAppShell.ts (4 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/BlazorUI/Bit.BlazorUI.Extras/Components/AppShell/BitAppShell.ts

[error] 14-14: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 51-51: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build and test
🔇 Additional comments (4)
src/BlazorUI/Bit.BlazorUI.Extras/Components/AppShell/BitAppShell.ts (4)

3-4: Good addition of a constant for session storage key.

Adding a named constant for the session storage key improves code maintainability and readability, making it easier to reference and update if needed in the future.


28-28: Improved scroll management with centralized logic.

Using the storeScroll method here is a good improvement that centralizes the scroll position management logic.


46-47: Improved scroll event handling with centralized storage.

Using the storeScroll method here simplifies the event handler and ensures consistent storage behavior across the application.


15-16: Verify null check implementation in conditional.

The exclamation mark in AppShell._scrolls[url]! is a non-null assertion operator that tells TypeScript to treat the value as non-null. Ensure this doesn't cause runtime errors if the value is actually undefined.

Verify that AppShell._scrolls[url] is always defined before this line executes, or consider a safer alternative:

- if (AppShell._scrolls[url]! > 0) {
+ if (AppShell._scrolls[url] && AppShell._scrolls[url] > 0) {

@msynk msynk merged commit 9779ca1 into bitfoundation:develop Mar 13, 2025
3 checks passed
@msynk msynk deleted the 10233-blazorui-appshell-store-scroll branch March 13, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The BitAppShell is missing a feature to store the persisted scroll position
2 participants