diff --git a/src/components/ToggleSwitch/ToggleSwitch.tsx b/src/components/ToggleSwitch/ToggleSwitch.tsx index 85c8338c18..a0ef41e8c2 100644 --- a/src/components/ToggleSwitch/ToggleSwitch.tsx +++ b/src/components/ToggleSwitch/ToggleSwitch.tsx @@ -52,7 +52,7 @@ export const ToggleSwitch: FC = ({ toggle(); }; - const handleKeyPress = (event: KeyboardEvent): void => { + const handleOnKeyUp = (event: KeyboardEvent): void => { event.preventDefault(); }; @@ -67,7 +67,7 @@ export const ToggleSwitch: FC = ({ disabled={disabled} id={`${id}-flowbite-toggleswitch`} onClick={handleClick} - onKeyPress={handleKeyPress} + onKeyUp={handleOnKeyUp} role="switch" tabIndex={0} type="button" @@ -79,7 +79,7 @@ export const ToggleSwitch: FC = ({ className={twMerge( theme.toggle.base, theme.toggle.checked[checked ? 'on' : 'off'], - !disabled && checked && theme.toggle.checked.color[color], + checked && theme.toggle.checked.color[color], )} /> {label?.length ? (