Skip to content

fix: AggregationPanel retains scroll position when loading from cache #2919

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

Open
wants to merge 6 commits into
base: alpha
Choose a base branch
from

Conversation

mtrezza
Copy link
Member

@mtrezza mtrezza commented Jul 17, 2025

Summary

  • reset the AggregationPanel scroll position when loading cached data

Testing

  • npm test

https://chatgpt.com/codex/tasks/task_e_6878f341055c832d8a72f833a9edf071

Summary by CodeRabbit

  • New Features
    • The aggregation panel in the Data Browser now automatically scrolls to the top when its data or selected object changes, improving navigation and visibility of updated content.

Copy link

The label codex cannot be used here.

Copy link

coderabbitai bot commented Jul 17, 2025

📝 Walkthrough

Walkthrough

A React ref named aggregationPanelRef was introduced in the DataBrowser component to reference the aggregation panel container DOM element. The component now resets the scroll position of this panel to the top whenever the aggregation data or selected object changes, provided the panel is visible.

Changes

File(s) Change Summary
src/dashboard/Data/Browser/DataBrowser.react.js Added aggregationPanelRef to reference aggregation panel container; resets scroll position on data or selection change; ref attached to aggregation panel container <div>.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DataBrowser
    participant AggregationPanel

    User->>DataBrowser: Changes AggregationPanelData or selectedObjectId
    DataBrowser->>AggregationPanel: Checks if panel is visible and ref is set
    DataBrowser->>AggregationPanel: Sets scrollTop to 0
Loading

Possibly related PRs

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error code ERR_SSL_WRONG_VERSION_NUMBER
npm error errno ERR_SSL_WRONG_VERSION_NUMBER
npm error request to https://10.0.0.28:4873/npm/-/npm-10.9.3.tgz failed, reason: C00CC402607F0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:354:
npm error
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-20T00_17_59_352Z-debug-0.log


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f7101ce and 3248cc6.

📒 Files selected for processing (1)
  • src/dashboard/Data/Browser/DataBrowser.react.js (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: mtrezza
PR: parse-community/parse-dashboard#2726
File: src/components/ContextMenu/ContextMenu.react.js:56-74
Timestamp: 2025-05-24T18:24:15.988Z
Learning: In the Parse Dashboard ContextMenu component, the one-time positioning calculation using hasPositioned ref works well even with window resizing and movement, so additional window resize event listeners are not necessary for menu positioning.
src/dashboard/Data/Browser/DataBrowser.react.js (1)
Learnt from: mtrezza
PR: parse-community/parse-dashboard#2828
File: src/dashboard/Data/Browser/Browser.react.js:1605-1607
Timestamp: 2025-05-27T12:09:47.644Z
Learning: In script execution dialogs in Parse Dashboard (specifically the `confirmExecuteScriptRows` method in `src/dashboard/Data/Browser/Browser.react.js`), individual `setState` calls to update `processedScripts` counter should be kept as-is rather than batched, because this provides real-time progress feedback to users in the dialog UI.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Node 20
  • GitHub Check: Node 18
  • GitHub Check: Docker linux/amd64
🔇 Additional comments (3)
src/dashboard/Data/Browser/DataBrowser.react.js (3)

135-135: LGTM! Clean ref initialization.

The React ref is properly created using React.createRef() and follows naming conventions.


220-227: Excellent implementation of scroll position reset logic.

The conditional checks are well-structured:

  • Properly detects changes in aggregation data and selected object
  • Includes defensive checks for panel visibility and ref existence
  • Efficiently resets scroll position to top when needed

This directly addresses the PR objective of preventing scroll position retention when loading from cache.


915-918: Proper ref attachment to scrollable container.

The ref is correctly attached to the container div, enabling scroll position control from the componentDidUpdate lifecycle method.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests 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

🚀 Thanks for opening this pull request!

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Jul 17, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

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 (2)
src/dashboard/Data/Browser/DataBrowser.react.js (2)

738-740: Consider also guarding horizontal scroll & potential null-state

  1. If the aggregation panel can scroll horizontally, you may also want to reset scrollLeft alongside scrollTop:
+      this.aggregationPanelRef.current.scrollLeft = 0;
  1. handleCallCloudFunction can be triggered before the panel is mounted (e.g. panel hidden), in which case this.aggregationPanelRef.current will still be null despite the outer null-check succeeding earlier in the lifecycle. You’re safe now, but keep it in mind if the call chain changes.

909-912: Ensure the container actually scrolls

scrollTop will have no effect unless .aggregationPanelContainer sets an overflow style (e.g. overflow-y: auto). Double-check Databrowser.scss contains something like:

.aggregationPanelContainer {
  overflow-y: auto;
}

Without it, the new behaviour will appear to work only when content exceeds the viewport by coincidence.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 17ce146 and d4bce76.

📒 Files selected for processing (1)
  • src/dashboard/Data/Browser/DataBrowser.react.js (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: mtrezza
PR: parse-community/parse-dashboard#2726
File: src/components/ContextMenu/ContextMenu.react.js:56-74
Timestamp: 2025-05-24T18:24:15.988Z
Learning: In the Parse Dashboard ContextMenu component, the one-time positioning calculation using hasPositioned ref works well even with window resizing and movement, so additional window resize event listeners are not necessary for menu positioning.
src/dashboard/Data/Browser/DataBrowser.react.js (1)
Learnt from: mtrezza
PR: parse-community/parse-dashboard#2828
File: src/dashboard/Data/Browser/Browser.react.js:1605-1607
Timestamp: 2025-05-27T12:09:47.644Z
Learning: In script execution dialogs in Parse Dashboard (specifically the `confirmExecuteScriptRows` method in `src/dashboard/Data/Browser/Browser.react.js`), individual `setState` calls to update `processedScripts` counter should be kept as-is rather than batched, because this provides real-time progress feedback to users in the dialog UI.
🔇 Additional comments (1)
src/dashboard/Data/Browser/DataBrowser.react.js (1)

135-136: Ref addition is correct and idiomatic

Creating aggregationPanelRef with React.createRef() in the constructor is the right approach for accessing the DOM node in a class component. No issues spotted.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 17, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 18, 2025
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.

2 participants