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

feature(checkbox): support proper indeterminate state #3584

Closed
lrstanley opened this issue Mar 17, 2025 · 5 comments
Closed

feature(checkbox): support proper indeterminate state #3584

lrstanley opened this issue Mar 17, 2025 · 5 comments
Labels
enhancement New feature or request needs reproduction v3 #1289

Comments

@lrstanley
Copy link

Description

Right now, it's only possible to have checkboxes be in an indeterminate state as its initial state, and not be able to go back to that state after it has moved away from that state. My use case is a checkbox that is used to control a query parameter for filtering results.

  • Indeterminate state: public = <true|false> results are included. and when the checkbox is false, it filters that public field by the value of the checkbox. Effectively, *, true, and false states.

Doesn't look as though this is possible today, with checkboxes, or with Switch.

I have attempted to re-set the value to indeterminate, however, it looks as though the Checkbox ignores this state change.

Additional context

No response

@lrstanley lrstanley added enhancement New feature or request triage v3 #1289 labels Mar 17, 2025
Copy link
Member

benjamincanac commented Mar 17, 2025

I haven't been able to reproduce this, tried adding a select in the playground to change the bound value and it works as planned:

<USelect v-model="checked" :items="[true, false, 'indeterminate']" />
<UCheckbox v-model="checked" />

Please fill up a bug report with a reproduction next time!

@benjamincanac benjamincanac closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2025
@lrstanley
Copy link
Author

@benjamincanac looks like in the playground, you are correct in that you can manually set the state back to indeterminate, but you still cannot change the state back to indeterminate with the checkbox itself, which was the reason for the feature request. Does this still not make sense as a feature request?

Copy link
Member

Oh you mean through the UI? You can take a look at this Table example to see how its done: https://ui.nuxt.com/components/table#with-row-selection

@lrstanley
Copy link
Author

lrstanley commented Mar 21, 2025

Oh you mean through the UI? You can take a look at this Table example to see how its done: ui.nuxt.com/components/table#with-row-selection

That is still not through the UI via the checkbox itself. That is through another event (and thus js/ts/etc, which technically could be trigger by something in the UI), which sets the state of the checkbox, which isn't quite the same. I'd like to toggle through all three states, just by clicking on the checkbox itself.

Copy link
Member

You might be able to achieve this manually by listening to the @update:model-value event and programatically change the value to indeterminate when it's already checked.

However, I don't think the indeterminate state should be used like that, it's only a visual change as you can read on https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs reproduction v3 #1289
Projects
None yet
Development

No branches or pull requests

2 participants