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

[switch] Should the switch have a toggle() method? #1046

Closed
gfellerph opened this issue Apr 26, 2024 · 1 comment · Fixed by #1097
Closed

[switch] Should the switch have a toggle() method? #1046

gfellerph opened this issue Apr 26, 2024 · 1 comment · Fixed by #1097
Labels
switch Switch control

Comments

@gfellerph
Copy link
Collaborator

Question in the explainer: https://open-ui.org/components/switch.explainer/#methods

Existing input elements don't have a toggle method. The value of checkboxes for example can be set trough the .value property in JavaScript. Switches only have two states and could easily be toggled. Should the switch support a .toggle method?

The proposed syntax for the toggle method would also allow for an optional force parameter:

mySwitch.toggle(): (force?: boolean) => boolean
@gregwhitworth gregwhitworth added the agenda+ Use this label if you'd like the topic to be added to the meeting agenda label Apr 30, 2024
@css-meeting-bot
Copy link

The Open UI Community Group just discussed [switch] Should the switch have a toggle() method?, and agreed to the following:

  • RESOLVED: input type="checkbox" switch will not have a toggle() method
The full IRC log of that discussion <bkardell_> q+
<masonf> q+
<brecht_dr> gregwhitworth: Should there be a toggle method on switch so that we can just call toggle, that changes the value
<gregwhitworth> ack bkardell_
<brecht_dr> bkardell_: This is for the input type variant. Do we still plan to do an element called switch? if so, is there support for that by vendors?
<brecht_dr> bkardell_: If this would apply to input, then i would like the answer to be "no", because input is already weird with all the variants, we shouldn't add more in my opinion.
<gregwhitworth> ack masonf
<brecht_dr> masonf: I had similar questions. I follow among the same lines. There is also a method called click, which is what you might want here
<Travis7> NICK Travis
<brecht_dr> masonf: I'd say let's just do that
<brecht_dr> gregwhitworth: I just wanted to call out that there isa toggle method (in chat meeting: https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/toggle)
<brecht_dr> gregwhitworth: I wonder what are we designing this for? That is the question
<bkardell_> sure... in an ideal world I would like a toggle on an element called switch
<brecht_dr> gregwhitworth: I'm in favour to say no for now, but this is an HTML centric decision
<gregwhitworth> q?
<gregwhitworth> Proposed Resolution: input type="checkbox" switch will not have a toggle() method
<masonf> +1
<bkardell_> +1
<brecht_dr> +1
<gregwhitworth> RESOLVED: input type="checkbox" switch will not have a toggle() method

@gregwhitworth gregwhitworth removed the agenda+ Use this label if you'd like the topic to be added to the meeting agenda label May 7, 2024
gfellerph added a commit to gfellerph/open-ui that referenced this issue Sep 23, 2024
After resolving to not add a toggle method in openui#1046 the question is answered and no further edits are necessary.
@gregwhitworth gregwhitworth added the switch Switch control label Sep 29, 2024
@gfellerph gfellerph linked a pull request Oct 10, 2024 that will close this issue
gfellerph added a commit that referenced this issue Oct 10, 2024
After resolving to not add a toggle method in #1046 the question is answered and no further edits are necessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
switch Switch control
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants