Skip to content

Commit 6707124

Browse files
committed
chore: rename preventdefault prop
1 parent 583c611 commit 6707124

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Common/Toggle/Toggle.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const Toggle = ({
2828
Icon = null,
2929
iconClass = '',
3030
throttleOnChange = false,
31-
preventDefaultOnLabel = false,
31+
shouldToggleValueOnLabelClick = false,
3232
...props
3333
}) => {
3434
const [active, setActive] = React.useState(selected)
@@ -62,7 +62,7 @@ const Toggle = ({
6262
}
6363

6464
const handleLabelClick = (e: SyntheticEvent) => {
65-
if (preventDefaultOnLabel) {
65+
if (shouldToggleValueOnLabelClick) {
6666
e.preventDefault()
6767
handleChange()
6868
}
@@ -73,7 +73,7 @@ const Toggle = ({
7373
{...props}
7474
className={`${rootClassName} toggle__switch ${disabled ? 'disabled' : ''}`}
7575
style={{ ['--color' as any]: color }}
76-
onClick={handleLabelClick}
76+
{...(shouldToggleValueOnLabelClick ? {onClick: handleLabelClick} : {})}
7777
>
7878
<input type="checkbox" checked={!!active} onChange={handleChange} className="toggle__input" />
7979
<span className={`toggle__slider ${Icon ? 'with-icon br-4 dc__border' : 'round'}`} data-testid={dataTestId}>

0 commit comments

Comments
 (0)