Skip to content

fix(frontend): highlight the file picked in the dataset file tree - #9526

Open
yangzhang75 wants to merge 2 commits into
apache:mainfrom
yangzhang75:fix/filetree-click-highlight
Open

yangzhang75 wants to merge 2 commits into
apache:mainfrom
yangzhang75:fix/filetree-click-highlight

Conversation

@yangzhang75

@yangzhang75 yangzhang75 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Closes #9501.

user-dataset-version-filetree is the file tree every dataset and model browser uses: the versions/files browser (dataset page, model page), the dataset-selection modal and the model-selection modal. Its click handler overrode the tree library's default click (TOGGLE_ACTIVE) with an emit of selectedTreeNode alone, so the tree never had an active node and the library never marked the clicked row. Where the host shows a preview (the dataset and model pages) the click had a visible result anyway; in the dataset-selection modal in file mode (a fileName property's Select File, e.g. CSV File Scan) the host only stores the path, so the picked file looked like every other row, the one sign of the pick was the Select button turning enabled, and re-clicking the picked file gave no feedback at all.

  • user-dataset-version-filetree.component.ts: a file click calls TREE_ACTIONS.ACTIVATE(tree, node, $event) before emitting -- ACTIVATE rather than TOGGLE_ACTIVE, so a second click on the picked file leaves it highlighted, as the selection it emits stands either way. Enter and Space on the focused node run the same handler: the library maps them to TOGGLE_ACTIVE by default, which would have stripped the highlight off the picked file while the host's selection stood, or marked a row the host never heard of. A key can also arrive with no node -- any mouse action, a hover included, focuses the tree, and only a file click focuses a node -- and then does nothing, as the library's own key actions do. Folders toggle as before, activating nothing.
  • isFileSelectable input (default true): a host that browses a version's files without holding one leaves nothing for a click to mean, and a highlighted row there would promise a pick nothing takes, so a file click activates and emits nothing where it is false. The dataset-selection modal binds it to its file mode (its version mode shows the tree only to browse) and the model-selection modal, whose tree is not bound to a handler at all, sets it false. Every host that never binds it keeps the click it has and gains the highlight.
  • user-dataset-version-filetree.component.scss: the library's active row (.node-content-wrapper-active) takes the ant blue-1 fill the dashboard's selected list rows and the workspace's selected cards share, with ant's primary blue as the ring and its blue-8 as the text colour (the primary blue reads at 2.95:1 on that fill, under the 4.5:1 text needs; blue-8 at 6.8:1), in place of the library's own #beebff-behind-a-grey-shadow; an inset shadow rather than a border, which would eat 2 px of the content box the row's icon buttons and centring rely on under the app's border-box sizing. The :hover copy keeps that fill on the picked row instead of the library's hover tint.

Left as it is, on purpose: the dataset and model pages preview a file on load without a click, and that file is not highlighted -- marking it needs the host to tell the tree which file it holds, which the UDF parameter-picker work adds (activeFilePath) and which belongs with it. Activating a node also lets the library scroll a row that is cut off at the viewport edge into view on click (scrollOnActivate), which it did not do before.

Video

Before

Screen.Recording.2026-11-22.at.10.02.14.PM.mov

After

Screen.Recording.2026-11-22.at.10.02.32.PM.mov

Any related issues, documentation, discussions?

Closes #9501. Found while building the UDF parameter pickers (#9338); independent of them.

How was this PR tested?

  • user-dataset-version-filetree.component.spec.ts: the two handler-level click tests (which called the handler with hand-made nodes) become a block that clicks real tree nodes through the library's own mouseAction dispatch, so what is pinned is the state the row's node-content-wrapper-active class is bound to: a file click emits selectedTreeNode and makes the file the active node; a second click on the same file keeps it active and emits it again; a click on another file moves the highlight; Enter and Space activate and emit as a click does, without toggling the pick off; Enter with the tree focused but no node focused (after a hover) does nothing and throws nothing; where files cannot be picked a file click activates and emits nothing while a folder still expands; the input defaults to true; a folder click toggles expansion, activates nothing and emits nothing. Deletion-checked: without the ACTIVATE call three of these fail; with the keys left at the library default, the Enter/Space one; without the isFileSelectable gate, the cannot-be-picked one.
  • user-dataset-version-filetree.component.browser.spec.ts (real rows under the virtual scroll, real computed styles): the clicked row carries the active class, its neighbour does not, the computed background, ring and colour are the component's rather than the library's, and the row's content box is still the full node height; where files cannot be picked a click leaves the row's class and background as they were. Deletion-checked: without the style rule the first fails.
  • The dataset-selection and model-selection modal specs pass with the new binding; the full frontend suite, eslint, prettier and the production (AOT) build pass.

Was this PR authored or co-authored using generative AI tooling?

Yes. Generated-by: Claude Code (Claude Fable 5.1, Anthropic). Co-authored with Claude, reviewed line by line by the author before submission.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @aglinxinyuan, @tanishqgandhi1908, @kunwp1
    You can notify them by mentioning @aglinxinyuan, @tanishqgandhi1908, @kunwp1 in a comment.

@Yicong-Huang Yicong-Huang added release/v1.3 back porting to release/v1.3 release/v1.2 back porting to release/v1.2 labels Nov 18, 2026
@github-actions
github-actions Bot requested review from mengw15 and xuang7 November 18, 2026 07:53
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. A release/* label nominates a backport target; the branch's release manager approving this PR is what sends the fix there. The required Backport Approvals check stays red until every label below is approved, so each manager either approves or removes their own label — which is why the labels left on a merged PR are exactly the branches it reached.

Release branch Analysis
🚫 release/v1.3 Label was removed earlier (opt-out); not re-added. Re-add it by hand if this fix should be backported here after all — the branch's release manager then has to approve before this PR can merge.
🚫 release/v1.2 Label was removed earlier (opt-out); not re-added. Re-add it by hand if this fix should be backported here after all — the branch's release manager then has to approve before this PR can merge.

Auto-label run.

@github-actions github-actions Bot added fix frontend Changes related to the frontend GUI labels Nov 18, 2026
@codecov-commenter

codecov-commenter commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.66%. Comparing base (95e2748) to head (f324dce).
⚠️ Report is 58 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9526      +/-   ##
============================================
- Coverage     91.67%   91.66%   -0.02%     
  Complexity     5135     5135              
============================================
  Files          1304     1306       +2     
  Lines         58088    57938     -150     
  Branches       7582     7575       -7     
============================================
- Hits          53254    53108     -146     
- Misses         2922     2923       +1     
+ Partials       1912     1907       -5     
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from 4f8fa41
agent-service 99.56% <ø> (ø) Carriedforward from 4f8fa41
amber 85.76% <ø> (ø) Carriedforward from 4f8fa41
computing-unit-managing-service 63.83% <ø> (ø) Carriedforward from 4f8fa41
config-service 87.50% <ø> (ø) Carriedforward from 4f8fa41
file-service 82.16% <ø> (ø) Carriedforward from 4f8fa41
frontend 96.45% <100.00%> (-0.01%) ⬇️
notebook-migration-service 83.77% <ø> (ø) Carriedforward from 4f8fa41
pyamber 98.38% <ø> (ø) Carriedforward from 4f8fa41
result-service 85.71% <ø> (ø) Carriedforward from 4f8fa41
workflow-compiling-service 78.30% <ø> (ø) Carriedforward from 4f8fa41

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xuang7

xuang7 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Removing the release labels: selecting a file still works.

@xuang7 xuang7 removed release/v1.2 back porting to release/v1.2 release/v1.3 back porting to release/v1.3 labels Nov 20, 2026
@yangzhang75
yangzhang75 force-pushed the fix/filetree-click-highlight branch from 33e44e1 to dfbb659 Compare November 23, 2026 06:09
The dataset file tree's click handler overrode the tree library's default
click (TOGGLE_ACTIVE) with an emit of selectedTreeNode alone, so the tree
never had an active node and the library never marked the clicked row: in
the dataset-selection modal, where the host only stores the path, the
picked file looked like every other and the one sign of the pick was the
Select button turning enabled. The handler now activates the clicked file
(ACTIVATE, not TOGGLE_ACTIVE, so a second click on the picked file keeps
it highlighted, as the selection it emits stands either way), Enter and
Space on the focused node do the same rather than the library's toggle,
and the component styles the active row like the app's selected rows,
with an inset shadow so the row keeps the height the virtual scroll pins.
Folders toggle as before.

A host that browses a version's files without holding one -- the dataset
picker in version mode, the model picker -- sets isFileSelectable false,
and a file click there activates and emits nothing: a highlighted row
would promise a pick nothing takes. Every other host keeps the click it
has and gains the highlight.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@mengw15 mengw15 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.

LGTM

Copilot AI 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.

🟡 Changes recommended

Selected filenames have insufficient text contrast (2.95:1 versus WCAG AA’s 4.5:1 minimum), requiring darker text and an updated browser test expectation.

1 open issue
What changed in this PR

This PR addresses #9501 by making clicked files visibly selected in the shared dataset/model file tree, while keeping browse-only trees non-selectable.

Changes:

  • Activates selected files on click, Enter, or Space, preserving the highlight on repeated selection.
  • Adds an isFileSelectable input and configures dataset/model selection modals appropriately.
  • Styles active rows and adds interaction and browser-rendering regression tests.
File Description
frontend/​src/​app/​workspace/​component/​model-selection-modal/​model-selection-modal.component.html Disables file selection in the model browser.
frontend/​src/​app/​workspace/​component/​dataset-selection-modal/​dataset-selection-modal.component.ts Exposes file mode to the template.
frontend/​src/​app/​workspace/​component/​dataset-selection-modal/​dataset-selection-modal.component.html Enables file selection only in file mode.
frontend/​src/​app/​dashboard/​component/​user/​user-dataset/​user-dataset-explorer/​user-dataset-version-filetree/​user-dataset-version-filetree.component.ts Unifies mouse and keyboard selection with persistent activation.
frontend/​src/​app/​dashboard/​component/​user/​user-dataset/​user-dataset-explorer/​user-dataset-version-filetree/​user-dataset-version-filetree.component.spec.ts Tests activation, repeated selection, keyboard actions, and folder expansion.
frontend/​src/​app/​dashboard/​component/​user/​user-dataset/​user-dataset-explorer/​user-dataset-version-filetree/​user-dataset-version-filetree.component.scss Adds active-row fill, text colour, and inset ring.
frontend/​src/​app/​dashboard/​component/​user/​user-dataset/​user-dataset-explorer/​user-dataset-version-filetree/​user-dataset-version-filetree.component.browser.spec.ts Tests rendered highlighting, styles, dimensions, and non-selectable rows.

Review effort: Balanced

@mengw15 mengw15 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.

Left one comment

// TOGGLE_ACTIVE by default, which would strip the highlight off the picked file, or mark a file
// the host never heard of.
private readonly activateOrExpand = (tree: any, node: any, $event: any): void => {
if (node.hasChildren) {

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.

node can be null on the key path: hovering a row or clicking a folder focuses the tree without focusing a node, so Enter/Space then throws Cannot read properties of null (reading 'hasChildren'). The library default guards with node &&.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right -- any mouse action focuses the tree (mouseAction calls setFocus(true) for the hover too) and only a file click focuses a node, so Enter after a hover or a folder click reached the handler with null. It returns on no node now, as the library's TOGGLE_ACTIVE does with node &&. The spec hovers a row, sends Enter through the tree's own onKeydown, and expects no throw, no active node and no emit; without the guard it throws exactly this TypeError (f324dce).

…and give the picked name 4.5:1

Review fixes on apache#9526. Any mouse action on a row -- a hover included --
focuses the tree, and only a file click also focuses a node, so Enter or
Space after hovering a row or opening a folder reached the key handler
with null and threw on `.hasChildren`; the handler now returns on no
node, as the library's own key actions do with `node &&`. The picked
file's name was ant's primary blue on the blue-1 fill, 2.95:1 where text
needs 4.5:1 (WCAG 1.4.3); it is ant's blue-8 now, 6.8:1 on the same fill,
with the ring left in the primary blue.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clicking a file in the dataset file tree leaves no visible trace: the picked row is never highlighted

6 participants