Skip to content

[AutoTable] Allow sorting by CustomCellColumn#937

Closed
adamrneary wants to merge 2 commits intogadget-inc:mainfrom
oaktownlabs:main
Closed

[AutoTable] Allow sorting by CustomCellColumn#937
adamrneary wants to merge 2 commits intogadget-inc:mainfrom
oaktownlabs:main

Conversation

@adamrneary
Copy link

Hey folks! I am new to contributing to this project. Should I be bumping package versions as part of this PR? Or should I be leaving that to Gadget folks? Happy to follow your guidelines.

Also happy to take any feedback on the approach. I think this change is desireable, but let me know if you don't think this is the right direction.

For context, I originally raised the issue here: https://discord.com/channels/836317518595096598/1446926428221210644. Then realized I could fix up the issue myself.

PR Checklist

  • Important or complicated code is tested
  • Any user facing changes are documented in the Gadget-side changelog
  • Any immediate changes are slated for release in Gadget via a generated package dependency bump
  • Versions within this monorepo are matching and there's a valid upgrade path

claude and others added 2 commits December 6, 2025 21:40
Added optional `field` and `sortable` properties to `CustomCellColumn` type,
enabling custom rendered columns to be sortable when a field path is provided.
The sortability is determined by the field's metadata, consistent with how
regular columns work.

Changes:
- Updated CustomCellColumn type with optional field and sortable properties
- Updated TableColumn union to allow field on CustomRenderer type
- Modified getTableColumns to determine sortability based on field metadata
- Updated Shadcn and Polaris table components to handle sortable custom columns
- Added tests for sortable custom column behavior
…rs-01VKFAGNpQfTYu9mbBXQvy5d

allow sorting columns with custom renderers by specifying a field
Copy link
Contributor

@MillanWangGadget MillanWangGadget left a comment

Choose a reason for hiding this comment

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

  • 🟢 passing in a field API id properly makes it sortable by that field
  • 🟡 Invalid input field API ids do not make the field sortable, but should throw an error so that you know immediately that you're trying to do something impossible
  • 🟡 Unsortable fields like File type fields can be passed in, but do nothing. Same as above with throwing an error when trying to do something impossible.
  • 🟡 Through-a-relationship fields like someHasManyField.edges.node.someFieldOnOtherModel can be passed in, and throw an error when you try to sort.
    • We don't currently support this in the API, and for now, I think it'd be better to throw an error on first render instead of on sort.
  • 🟡 In type:"CustomRenderer" columns, I think it'd be nice to rename the added property to be something like sortByField to be more clear that it's only gonna be used for sorting.

@MillanWangGadget
Copy link
Contributor

Closing with implementation in here #961

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.

3 participants