Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/table sortable field #1477

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Feat/table sortable field #1477

wants to merge 2 commits into from

Conversation

devara
Copy link
Contributor

@devara devara commented Sep 17, 2024

Add sortable on Table Static

#443

@devara devara added the enhancement New feature or request label Sep 17, 2024
@devara devara requested a review from adenvt September 17, 2024 15:30
@devara devara self-assigned this Sep 17, 2024
Copy link

vercel bot commented Sep 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
design-system ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 17, 2024 3:30pm

@adenvt
Copy link
Contributor

adenvt commented Sep 19, 2024

@devara hmm... Any example to use this with list from API?

And also, i see this can be sorting using multiple fields at once? but how if we want to use with only single field?

In most API we have, it's accept only single sort_by. example if we click sort by name, click create_at should be remove sort by name and enable sort by create_at.
current implementation will enable both sort by name and create_at.

@devara
Copy link
Contributor Author

devara commented Sep 20, 2024

@adenvt , if use list from the API, items on the table will not be sorted immediately, just emit the sorted key & value, so page/component that use the Table comp can do the desired action (I already add the prop for sortable asyncronous).

About the multiple sort, maybe we can add new prop to set Table comp to only perform single sort key. But I already add new property when we define table fields (sortable), so if we only want to sort single field, we just add sortable on the specific field, not all field (currently default value is FALSE)

@@ -25,13 +25,23 @@
class="table-static__header"
data-testid="table-static-header"
:style="field.width ? { width: withUnit(field.width) } : {}"
:class="field.thClass"
:data-header="field.key">
:class="[field.thClass, { 'table-static__header--sortable': sortable && field.sortable }]"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adenvt
Even if the sortable prop is provided when calling the Table component, but the field is not sortable, it will not be sorted.

})

async function sortField (field: TableField<T>) {
if (!props.sortable || !field.sortable || field.sortable === undefined)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adenvt
I also added a check here, when the field is not sortable it will not be sorted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

Table: Sorting by Field Name
2 participants