Skip to content

ToggleSwitch simplified #925

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

Closed
2 tasks done
victorfunes opened this issue Aug 22, 2023 · 4 comments
Closed
2 tasks done

ToggleSwitch simplified #925

victorfunes opened this issue Aug 22, 2023 · 4 comments
Labels
good first issue Good for newcomers 🚀 enhancement New feature or request

Comments

@victorfunes
Copy link

  • I have searched the Issues to see if this bug has already been reported
  • I have tested the latest version

Summary

The ToggleSwitch component is requiring always parameters that are not always being to be used.
Request: change to optional some of them.

Context

I am creating a form just to visualize information, and due to the screen design, I cannot use the embedded label, but it is mandatory to define one.
As it is only for information, it is not going to change, but the onChange function is also mandatory.

Example: I have to implement this design using label="" and onChange={() => {}} and generating unnecessary warnings in my code.

image

            <Label
              htmlFor={"automatedAssignment"}
              className="text-xs font-normal text-gray-900 select-none">
              Allow automatic assignment
            </Label>
            <ToggleSwitch
              id="automatedAssignment"
              label=""
              color="blue"
              checked={automaticAssignmentEnabled ?? false}
              onChange={() => {}}
            />
@andreaTarascioSophany
Copy link
Contributor

Hi! I'm picking up this issue

andreaTarascioSophany added a commit to SophanySC/flowbite-react-sophany that referenced this issue Aug 23, 2023
rluders pushed a commit that referenced this issue Sep 21, 2023
* refactor(toggleswitch.tsx): toggleSwitch optional props

ToggleSwitch optional props

#925

* refactor(better sintax): improved quality of code

improved quality of code
@rluders rluders closed this as completed Sep 23, 2023
@rluders rluders reopened this Sep 25, 2023
@rluders
Copy link
Collaborator

rluders commented Sep 25, 2023

Still missing the onChange

@rluders rluders added 🚀 enhancement New feature or request good first issue Good for newcomers labels Sep 29, 2023
maman pushed a commit to transkripid/flowbite-react that referenced this issue Oct 7, 2023
* refactor(toggleswitch.tsx): toggleSwitch optional props

ToggleSwitch optional props

themesberg#925

* refactor(better sintax): improved quality of code

improved quality of code
@SutuSebastian
Copy link
Collaborator

SutuSebastian commented Jun 20, 2024

Still missing the onChange

Unless we make it have internal state (or have the button listen to vanilla input checked state) so that it becomes uncontrolled, we need to enforce checked and onChange props.

Or we provide onChange a default of () => null

@SutuSebastian
Copy link
Collaborator

Fixed by #1498 in [email protected] release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers 🚀 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants