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

[Table] Add option for "null" sort (when initialized with a default sort). #1684

Closed
caiotarifa opened this issue Apr 18, 2024 · 2 comments
Closed
Labels
enhancement New feature or request v3 #1289 wontfix-v2 This will not be fixed in `v2.x`.

Comments

@caiotarifa
Copy link

Description

I don't know if this is a bug or a feature (haha).

In some cases, I need to initialize my sort with data from a URL. For example, I may have the following URL:

/page?sort=name

To make this possible, I use:

const { query } = useRoute()

const sort = ref({
  column: query.sort?.replace(/^-/, ''),
  direction: query.sort?.startsWith('-') ? 'desc' : 'asc'
})

It works like a charm, but since a default sort has been defined, the component assumes that the column (in this case, "name") must always have a sort. In other words, the third state (null) ceases to exist, and this sort must necessarily be either ascending or descending.

My suggestion would be to add a new property default to the sort object, something like:

const sort = ref({
  column: 'name',
  direction: 'asc',
  default: true
})

When true , the current behavior would remain. When false, the "null" sort would again be a possibility.

Additional context

No response

@caiotarifa caiotarifa added the enhancement New feature or request label Apr 18, 2024
@caiotarifa
Copy link
Author

Hoping to see it fixed in #2139.

@benjamincanac benjamincanac added wontfix-v2 This will not be fixed in `v2.x`. v3 #1289 labels Nov 10, 2024
@benjamincanac
Copy link
Member

You should be able to achieve that in v3 yes since we're using TanStack Table now: https://ui3.nuxt.dev/components/table#with-column-sorting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v3 #1289 wontfix-v2 This will not be fixed in `v2.x`.
Projects
None yet
Development

No branches or pull requests

2 participants