[PR #4965] [MERGED] fix: scroll active sidebar items into view #4847

Closed
opened 2026-02-22 18:36:39 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/4965
Author: @angelplusultra
Created: 2/4/2026
Status: Merged
Merged: 2/6/2026
Merged by: @timothycarambat

Base: masterHead: 4963-sidebar-selection-srcoll-into-view


📝 Commits (5)

  • 389fa36 Add centering of settings sidebar link when isActive
  • 6418ba5 abstract redundant logic into a reusable hook
  • 3eeb6ca add jsdocs | refactor hook to consume behavior and block args
  • 6be152d remove unused import
  • ede9353 dev

📊 Changes

4 files changed (+52 additions, -7 deletions)

View changed files

📝 .github/workflows/dev-build.yaml (+1 -1)
📝 frontend/src/components/SettingsSidebar/MenuOption/index.jsx (+14 -6)
📝 frontend/src/components/Sidebar/ActiveWorkspaces/ThreadContainer/ThreadItem/index.jsx (+7 -0)
frontend/src/hooks/useScrollActiveItemIntoView.js (+30 -0)

📄 Description

Pull Request Type

  • feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

Relevant Issues

resolves #4963

What is in this change?

This PR fixes the sidebar selection scroll behavior so that active items are automatically scrolled into view when selected.

Changes:

  • Added a new reusable hook useScrollActiveItemIntoView that handles scrolling an element into the viewport when it becomes active
  • Applied the hook to MenuOption in the Settings Sidebar so the currently selected setting is scrolled to center view
  • Applied the hook to ThreadItem in the main Sidebar so the active thread is scrolled to center view
  • Uses behavior: "instant" to avoid visible scroll animation artifacts (since sidebars remount on navigation, smooth scrolling would animate from the top)

Additional Information

The instant behavior is used intentionally because the Settings Sidebar remounts on each page navigation. Using smooth would cause a visible scroll animation from the top of the sidebar to the active item every time you navigate.

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/4965 **Author:** [@angelplusultra](https://github.com/angelplusultra) **Created:** 2/4/2026 **Status:** ✅ Merged **Merged:** 2/6/2026 **Merged by:** [@timothycarambat](https://github.com/timothycarambat) **Base:** `master` ← **Head:** `4963-sidebar-selection-srcoll-into-view` --- ### 📝 Commits (5) - [`389fa36`](https://github.com/Mintplex-Labs/anything-llm/commit/389fa36a7041ee365b28462e31e1734cb0edff67) Add centering of settings sidebar link when isActive - [`6418ba5`](https://github.com/Mintplex-Labs/anything-llm/commit/6418ba50794bec18bf3fcbfc780ba87486750776) abstract redundant logic into a reusable hook - [`3eeb6ca`](https://github.com/Mintplex-Labs/anything-llm/commit/3eeb6caf3852cbfb4d39450683fbb0afcb68698b) add jsdocs | refactor hook to consume behavior and block args - [`6be152d`](https://github.com/Mintplex-Labs/anything-llm/commit/6be152d39bb55e3f3ad1fb71c5168f203c512431) remove unused import - [`ede9353`](https://github.com/Mintplex-Labs/anything-llm/commit/ede9353b405dabe64831e3c59bb11c7e43f9c80b) dev ### 📊 Changes **4 files changed** (+52 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/dev-build.yaml` (+1 -1) 📝 `frontend/src/components/SettingsSidebar/MenuOption/index.jsx` (+14 -6) 📝 `frontend/src/components/Sidebar/ActiveWorkspaces/ThreadContainer/ThreadItem/index.jsx` (+7 -0) ➕ `frontend/src/hooks/useScrollActiveItemIntoView.js` (+30 -0) </details> ### 📄 Description ### Pull Request Type - [ ] ✨ feat - [x] 🐛 fix - [ ] ♻️ refactor - [ ] 💄 style - [ ] 🔨 chore - [ ] 📝 docs ### Relevant Issues resolves #4963 ### What is in this change? This PR fixes the sidebar selection scroll behavior so that active items are automatically scrolled into view when selected. **Changes:** - Added a new reusable hook `useScrollActiveItemIntoView` that handles scrolling an element into the viewport when it becomes active - Applied the hook to `MenuOption` in the Settings Sidebar so the currently selected setting is scrolled to center view - Applied the hook to `ThreadItem` in the main Sidebar so the active thread is scrolled to center view - Uses `behavior: "instant"` to avoid visible scroll animation artifacts (since sidebars remount on navigation, smooth scrolling would animate from the top) ### Additional Information The `instant` behavior is used intentionally because the Settings Sidebar remounts on each page navigation. Using `smooth` would cause a visible scroll animation from the top of the sidebar to the active item every time you navigate. ### Developer Validations - [x] I ran `yarn lint` from the root of the repo & committed changes - [x] Relevant documentation has been updated - [x] I have tested my code functionality - [x] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:36:39 -05:00
yindo closed this issue 2026-02-22 18:36:39 -05:00
yindo changed title from [PR #4965] fix: scroll active sidebar items into view to [PR #4965] [MERGED] fix: scroll active sidebar items into view 2026-06-05 15:20:41 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4847