Repository navigation
fix(frontend): highlight the file picked in the dataset file tree - #9526
yangzhang75 wants to merge 2 commits into
Conversation
Automated Reviewer SuggestionsBased on the
|
Backport auto-label reportThis
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Removing the release labels: selecting a file still works. |
33e44e1 to
dfbb659
Compare
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>
dfbb659 to
4f8fa41
Compare
There was a problem hiding this comment.
🟡 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
isFileSelectableinput 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
| // 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) { |
There was a problem hiding this comment.
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 &&.
There was a problem hiding this comment.
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

What changes were proposed in this PR?
Closes #9501.
user-dataset-version-filetreeis 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 ofselectedTreeNodealone, 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 (afileNameproperty'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 callsTREE_ACTIONS.ACTIVATE(tree, node, $event)before emitting --ACTIVATErather thanTOGGLE_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 toTOGGLE_ACTIVEby 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.isFileSelectableinput (defaulttrue): 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 isfalse. 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 itfalse. 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:hovercopy 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 ownmouseActiondispatch, so what is pinned is the state the row'snode-content-wrapper-activeclass is bound to: a file click emitsselectedTreeNodeand 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 totrue; a folder click toggles expansion, activates nothing and emits nothing. Deletion-checked: without theACTIVATEcall three of these fail; with the keys left at the library default, the Enter/Space one; without theisFileSelectablegate, 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.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