Skip to content

Conversation

@interim17
Copy link
Contributor

@interim17 interim17 commented May 12, 2025

Problem

Closes #141 and #165

Solution

Add sorter functions to each column object in getNormalTableColumns
Implement state, change handler, and necessary details for styling in CellLineTable

  • New feature (non-breaking change which adds functionality)

Screenshot 2025-05-12 at 10 20 50 AM

@netlify
Copy link

netlify bot commented May 12, 2025

Deploy Preview for cell-catalog ready!

Name Link
🔨 Latest commit 5dfef4a
🔍 Latest deploy log https://app.netlify.com/projects/cell-catalog/deploys/68253a80b1c47e0008c09d48
😎 Deploy Preview https://deploy-preview-162--cell-catalog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@interim17 interim17 marked this pull request as ready for review May 12, 2025 17:35
@interim17 interim17 requested review from meganrm and rugeli and removed request for meganrm May 12, 2025 17:35
const { lastColumn } = require("../../style/table.module.css");

/* case insensitive string comparison */
const compareStrings = (a = "", b = "") =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit, but could call this caseInsenstiveStringCompare and then you don't need the comment

@meganrm
Copy link
Collaborator

meganrm commented May 12, 2025

when I click the arrow a third time it does something weird
Screenshot 2025-05-12 at 11 16 29 AM

@meganrm
Copy link
Collaborator

meganrm commented May 12, 2025

should the down arrow for cell id be highlighted on load since that's what's being sorted on by default? (the prototype travis made isn't loading for me right now so I can't see the design)

const [sortedColumn, setSortedColumn] = useState<{
key: string;
order: SortOrder;
}>({ key: "", order: null });
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't it sorted on id by default?

@interim17 interim17 requested a review from meganrm May 12, 2025 19:52
return column;
}
const isSortedColumn = sortedColumn.key === column.key;
const sortIcon =
Copy link
Collaborator

Choose a reason for hiding this comment

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

non-blocking: from my personal user experience, adding tooltips like Sort A-Z or Ascending/Descending to the sort icon would be very helpful.

@rugeli
Copy link
Collaborator

rugeli commented May 12, 2025

Also noticing the clicking issues Megan mentioned:

  1. For the fluorescent tag, tag location columns, there seems to be a "no reaction" on every third click (pattern: up, down, nothing happens)
  2. For protein, gene symbol & name and structure columns, there's a similar issue but slightly different: on that third click, the sorting actually happens but the arrow direction doesn't update to match
    2.5 nit: the sorting pattern seems a bit off, for example, clicking three times on protein, the top one will go paxillin-alpha-actinin-2- Vascular endothelial (VE)-cadherin. This may resolve itself once we fix 2.

(Just saw the latest commit for fixing the undefined third click, looks like it still persists though? Happy to help test more if needed!)

@interim17
Copy link
Contributor Author

Also noticing the clicking issues Megan mentioned:

  1. For the fluorescent tag, tag location columns, there seems to be a "no reaction" on every third click (pattern: up, down, nothing happens)
  2. For protein, gene symbol & name and structure columns, there's a similar issue but slightly different: on that third click, the sorting actually happens but the arrow direction doesn't update to match
    2.5 nit: the sorting pattern seems a bit off, for example, clicking three times on protein, the top one will go paxillin-alpha-actinin-2- Vascular endothelial (VE)-cadherin. This may resolve itself once we fix 2.

(Just saw the latest commit for fixing the undefined third click, looks like it still persists though? Happy to help test more if needed!)

I only added the value for the third click on the ID column initially, I just added it to the other array so that all columns have all three values, looks like that might fix it?

@interim17 interim17 requested a review from rugeli May 14, 2025 01:41
Copy link
Collaborator

@rugeli rugeli left a comment

Choose a reason for hiding this comment

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

The fix looks good! Bugs I've seen are all cleared up!

}
return {
...interactiveColumn,
sorter: undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do you have to do this? shouldn't it already be undefined if it's not a sortable column?

onCell: onCellInteraction,
};
if (sortableTable && column.sorter) {
return applySortingProperties(interactiveColumn);
Copy link
Collaborator

Choose a reason for hiding this comment

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

can't you just check if it has a sorter?

expandable={isTablet ? mobileConfig : undefined}
columns={interactiveColumns}
dataSource={cellLines}
onChange={sortableTable ? onSortingChange : undefined}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you need this check

@interim17 interim17 merged commit 7a907a2 into main May 15, 2025
4 checks passed
@interim17 interim17 deleted the feature/table-sort branch May 15, 2025 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sort on columns

4 participants