Skip to content

feat: package code file tree should keep active file in view - #1977

Merged
ghostdevv merged 11 commits into
npmx-dev:mainfrom
btea:feat/file-tree-scoll-to-active-node
Jul 7, 2026
Merged

feat: package code file tree should keep active file in view#1977
ghostdevv merged 11 commits into
npmx-dev:mainfrom
btea:feat/file-tree-scoll-to-active-node

Conversation

@btea

@bteabtea commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Scroll the active file in the files list into view when it's clicked/page loaded

🧭 Context

📚 Description

When switching files in the code file tree area, the selected file will automatically jump to the center of the area.

@vercel

vercelBot commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
npmx.devReadyReadyPreview, CommentJul 7, 2026 2:35am
2 Skipped Deployments
ProjectDeploymentActionsUpdated (UTC)
docs.npmx.devIgnoredIgnoredPreviewJul 7, 2026 2:35am
npmx-lunariaIgnoredIgnoredJul 7, 2026 2:35am

Request Review

@codecov

codecovBot commented Mar 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing linesPatch %Lines
app/components/Code/FileTree.vue83.33%0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai

coderabbitaiBot commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a treeRoot ref to the file tree, queries the active node via aria-current="true", and scrolls it into view after currentPath changes and ancestor expansion completes.

Changes

File tree current-node scrolling

Layer / File(s)Summary
Root ref, scroll helper, and watcher
app/components/Code/FileTree.vue
Creates a treeRoot template ref, binds it to the root <ul>, and adds watcher logic that expands ancestors then scrolls the active node into view.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description check✅ PassedThe description is on-topic and describes the same file-tree auto-scroll behaviour.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Title check✅ PassedThe title clearly describes the main change: keeping the active file in the code file tree in view.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb857c39-22d7-4d7d-bdb1-c3dad6a02d27

📥 Commits

Reviewing files that changed from the base of the PR and between 0d952fa and 30a4dce.

📒 Files selected for processing (1)
  • app/components/Code/FileTree.vue

Comment threadapp/components/Code/FileTree.vue

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
app/components/Code/FileTree.vue (1)

40-45: Consider using generic querySelector for type safety.

The type assertion as HTMLElement works but could be tightened. Using the generic form avoids a cast and aligns with the coding guideline for strictly type-safe code.

Suggested improvement
 const scrollIntoView = () => {
- const el = treeRoot.value?.querySelector('[aria-current="true"]') as HTMLElement+ const el = treeRoot.value?.querySelector<HTMLElement>('[aria-current="true"]')
if (el) {
el.scrollIntoView({ block: 'center' })
}
}

As per coding guidelines: "Ensure you write strictly type-safe code, for example by ensuring you always check when accessing an array value by index."


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 52934022-cdcd-4f8b-b5df-3d63f0824666

📥 Commits

Reviewing files that changed from the base of the PR and between 30a4dce and ab14372.

📒 Files selected for processing (1)
  • app/components/Code/FileTree.vue

@ghostdevvghostdevv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is an interesting bug where if you load the page on a small screen when it scrolls the scroll isn't contained to the file tree

@btea

btea commented Mar 10, 2026

Copy link
Copy Markdown
ContributorAuthor

I tested it with the preview link, and when I clicked the icon in the lower right corner to expand the side tree structure, it correctly retrieved the node and scrolled the node into the view area.

@ghostdevvghostdevv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can't reproduce the scroll issue I had a couple weeks back, so LGTM!

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
app/components/Code/FileTree.vue (1)

45-50: ⚠️ Potential issue | 🟠 Major

Run the path watcher only from the root tree instance.

At Line 45, this watcher still executes in every recursive CodeFileTree instance. That can queue repeated nextTick(scrollIntoView) calls (Line 50) and redundant autoExpandAncestors work on each path change.

Proposed fix
 watch(
() => props.currentPath,
path => {
- if (path) {+ if (path && depth.value === 0) {
autoExpandAncestors(path)
nextTick(scrollIntoView)
}
},
{ immediate: true },
)

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 95746bab-bc3a-40d5-ae1f-f6c1e2a49c9e

📥 Commits

Reviewing files that changed from the base of the PR and between 57eec3e and 0a0d6da.

📒 Files selected for processing (1)
  • app/components/Code/FileTree.vue

@ghostdevvghostdevv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ah wait, it seems to still scroll even when the thing is already visible 🤔

@btea

btea commented Mar 22, 2026

Copy link
Copy Markdown
ContributorAuthor

In this case, the smooth effect should probably be removed.

@ghostdevv

Copy link
Copy Markdown
Member

In this case, the smooth effect should probably be removed.

The smooth made it much more obvious but it happens without it 🫠

@btea

btea commented Mar 22, 2026

Copy link
Copy Markdown
ContributorAuthor

That's true. But I think the silky smooth scrolling effect looks good right now. 😄

@github-actionsgithub-actionsBot added stale This has become stale and may be closed soon and removed stale This has become stale and may be closed soon labels May 10, 2026
@github-actionsgithub-actionsBot added the stale This has become stale and may be closed soon label Jun 10, 2026
@btea

btea commented Jun 18, 2026

Copy link
Copy Markdown
ContributorAuthor

@ghostdevv Can this PR be restarted?

@ghostdevvghostdevv reopened this Jun 27, 2026
@gameromangameroman removed stale This has become stale and may be closed soon stale-to-close labels Jun 27, 2026
@ghostdevv
ghostdevvforce-pushed the feat/file-tree-scoll-to-active-node branch from 16c1191 to 8a75324CompareJuly 7, 2026 02:34
@ghostdevvghostdevv changed the title feat: code file tree switch file to active nodefeat: package code file tree should keep active file in viewJul 7, 2026
@ghostdevv
ghostdevv added this pull request to the merge queueJul 7, 2026
Merged via the queue into npmx-dev:main with commit 3b651c2Jul 7, 2026
25 checks passed
@github-actionsgithub-actionsBot mentioned this pull request Jul 7, 2026
@btea
btea deleted the feat/file-tree-scoll-to-active-node branch July 7, 2026 07:26
ayo-run pushed a commit to ayo-run/npmx.dev that referenced this pull request Aug 5, 2026
…v#1977)
Co-authored-by: Alex Savelyev <91429106+alexdln@users.noreply.github.com>
Co-authored-by: Willow (GHOST) <git@willow.sh>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontFrontend, Design

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@btea@ghostdevv@gameroman@alexdln