feat: Add component sorting by any metric in metrics.tsv - #125
Merged
Conversation
…ME-ICA#124) - Clicking a column header sorts the component table by that metric (desc → asc → clear) - Active sort column is highlighted in blue with ↑/↓ indicator - Arrow-key figure navigation follows the same sorted order - Sort preference persists across page reloads via localStorage Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
✅ Deploy Preview for rica-fmri ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Collaborator
Author
|
How is this @tsalo ? |
Member
|
This looks really great! Just a couple of notes:
|
…avigation - Replace DISPLAY_COLUMNS whitelist with PRIORITY_COLUMNS that includes all labeled metrics (normalized variance explained, countsigFT2, countsigFS0, signal-noise_p, optimal sign, variance explained rank, rationale); any additional TSV columns are appended after the priority list - Replace row.scrollIntoView() with container.scrollTo() so arrow-key navigation only scrolls within the metrics table, not the whole page Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
Author
Member
|
The new version looks great! Thank you! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds sortable component metrics and aligns keyboard left/right navigation with the same ordering, persisting the chosen sort (column + direction) in localStorage.
Changes:
- Added
sortColumn/sortDirectionstate inPlots, persisted vialocalStorage, and used to compute anavigationOrder+sortedIndices. - Updated keyboard left/right navigation to follow
navigationOrderinstead of the pie chart’s order only. - Updated
ComponentTableto render columns dynamically (priority list + TSV extras) and make headers clickable with a sort indicator.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Plots/Plots.js | Adds sort state/persistence, computes sorted navigation order, and wires sort + indices into the table and hotkeys. |
| src/Plots/ComponentTable.js | Adds clickable headers with sort indicator, supports extra TSV columns, and renders rows using provided sorted indices. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix string-column sort: use localeCompare instead of subtraction to avoid NaN when sorting Component, classification, tags, etc. - Fix null handling: push missing values to end instead of treating as 0 - Fix cleared-sort table order: sortedIndices now returns original TSV order when no sort column is active (keyboard arrow navigation still uses pieData grouping as before) - Fix sortedIndices empty-array falsy bug: guard with Array.isArray + length check before using sortedIndices in table body - Fix accessibility: move sort onClick from <th> to a <button> inside each header; add aria-sort attribute to active column Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #124
This PR adds the ability to sort components by any metric in
metrics.tsvand loop over component figures in that order.localStorageChanged files
src/Plots/ComponentTable.js— clickable<th>headers with sort indicator; row rendering now iteratessortedIndicesso rows reorder whileselectedIndexstays anchored to original TSV positionssrc/Plots/Plots.js—sortColumn/sortDirectionstate,navigationOrdermemo (drives both table and keyboard nav),handleSortcallback, new props passed toComponentTableTest plan
🤖 Generated with Claude Code