Skip to content

Conversation

@DC-Dancao
Copy link

@DC-Dancao DC-Dancao commented Sep 2, 2025

Description

This PR implements independent scroll positions for each tab within the settings view, enhancing user experience. Previously, the scroll position was shared across all tabs, causing incorrect scrollbar behavior when switching between tabs of different lengths. Now, the view remembers each tab's scroll position, restoring it when the user navigates back.

Changes

  • src/components/Tab.tsx: Enabled ref forwarding for the TabContent component to allow parent access.

  • src/views/SettingsView.tsx: Implemented logic to save and restore individual scroll positions when switching tabs.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Important

Implements independent scroll positions for each tab in settings, enhancing user experience by restoring positions when switching tabs.

  • Behavior:
    • Implements independent scroll positions for each tab in SettingsView.tsx, restoring them when switching tabs.
    • Previously, scroll position was shared across tabs, causing incorrect behavior.
  • Components:
    • Enables ref forwarding in TabContent in Tab.tsx to allow parent access.
    • Uses useRef and useEffect in SettingsView.tsx to manage scroll positions.
  • Functions:
    • handleTabChange and useEffect in SettingsView.tsx updated to save and restore scroll positions.

This description was created by Ellipsis for ad07bf4. You can customize this summary. It will automatically update as commits are pushed.

@DC-Dancao DC-Dancao requested review from cte, jr and mrubens as code owners September 2, 2025 01:21
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Sep 2, 2025
Copy link

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! I've reviewed the changes and found that the implementation successfully addresses the scroll position preservation issue. However, there are a few suggestions that could improve the code quality and maintainability.

</div>
)
}
})
Copy link

Choose a reason for hiding this comment

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

The forwardRef component should have a display name for better debugging and React DevTools support. Consider adding:

Suggested change
})
TabContent.displayName = 'TabContent'

right after the component definition.

const scrollPositions = useRef<Record<SectionName, number>>(
Object.fromEntries(sectionNames.map((s) => [s, 0])) as Record<SectionName, number>,
)
const contentRef = useRef<HTMLDivElement | null>(null)
Copy link

Choose a reason for hiding this comment

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

Consider using a more descriptive variable name like tabContentScrollRef instead of contentRef to better indicate its specific purpose of tracking scroll positions.

)

const scrollPositions = useRef<Record<SectionName, number>>(
Object.fromEntries(sectionNames.map((s) => [s, 0])) as Record<SectionName, number>,
Copy link

Choose a reason for hiding this comment

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

The scroll positions are stored indefinitely in the ref. While not critical for a small number of tabs, consider if any cleanup is needed when the component unmounts to prevent potential memory leaks in long-running sessions.

contentRef.current.scrollTop = scrollPositions.current[activeTab] ?? 0
}
})
}, [activeTab])
Copy link

Choose a reason for hiding this comment

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

Consider adding test coverage for the scroll position preservation functionality. The PR checklist indicates "Testing" is unchecked. Adding tests would help ensure this feature works correctly and prevent regressions. You could test:

  • Scroll position is saved when switching tabs
  • Scroll position is restored when returning to a tab
  • Initial scroll position is 0 for unvisited tabs

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 2, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Sep 3, 2025
@RooCodeInc RooCodeInc deleted a comment from roomote bot Sep 3, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 3, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Sep 3, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

Thank you @DC-Dancao!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 3, 2025
@mrubens mrubens merged commit 1f5ee43 into RooCodeInc:main Sep 3, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Sep 3, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 3, 2025
@DC-Dancao DC-Dancao deleted the scrollbar branch September 8, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Preliminary Review size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants