]> git.localhorst.tv Git - alttp.git/commitdiff
refine toggle switch a11y
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 30 Jul 2025 20:36:27 +0000 (22:36 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 30 Jul 2025 20:36:27 +0000 (22:36 +0200)
resources/js/components/common/ToggleSwitch.jsx

index 22bb7523ddf164ce80aaaf2bf370647dfb8618e6..f9d4838af8dfb5502ca8cbb8731eee1709f39838 100644 (file)
@@ -26,14 +26,6 @@ const ToggleSwitch = ({
                toggle();
        };
 
-       const handleKey = event => {
-               if ([13, 32].includes(event.which)) {
-                       toggle();
-                       event.preventDefault();
-                       event.stopPropagation();
-               }
-       };
-
        const classNames = ['form-control', 'custom-toggle'];
        if (value) classNames.push('is-toggled');
        if (isInvalid) classNames.push('is-invalid');
@@ -44,11 +36,9 @@ const ToggleSwitch = ({
                aria-checked={value ? 'true' : 'false'}
                className={classNames.join(' ')}
                id={id}
-               role="switch"
                onBlur={onBlur ? () => onBlur({ target: { name, value } }) : null}
                onClick={handleClick}
-               onKeyDown={handleKey}
-               tabIndex="0"
+               role="switch"
                title={title}
                type="button"
        >