File tree Expand file tree Collapse file tree 6 files changed +22
-19
lines changed
Expand file tree Collapse file tree 6 files changed +22
-19
lines changed Original file line number Diff line number Diff line change 33import * as React from 'react' ;
44import { hasReactNode } from '@vkontakte/vkjs' ;
55import { useMergeProps } from '../../hooks/useMergeProps' ;
6- import { onLabelClickWrapper } from '../../lib/onLabelClickWrapper' ;
76import { warnOnce } from '../../lib/warnOnce' ;
7+ import { withLabelClickWrapper } from '../../lib/withLabelClickWrapper' ;
88import type { HasDataAttribute , HasRootRef } from '../../types' ;
99import { SelectionControl } from '../SelectionControl/SelectionControl' ;
1010import { SelectionControlLabel } from '../SelectionControl/SelectionControlLabel/SelectionControlLabel' ;
@@ -145,7 +145,7 @@ const CheckboxComponent = ({
145145 hasActive = { hasActive }
146146 focusVisibleMode = { focusVisibleMode }
147147 noPadding = { noPadding }
148- onClick = { onLabelClickWrapper ( onClick ) }
148+ onClick = { withLabelClickWrapper ( onClick ) }
149149 { ...rootRest }
150150 >
151151 < CheckboxInput
Original file line number Diff line number Diff line change 33import { classNames } from '@vkontakte/vkjs' ;
44import { useAdaptivity } from '../../../hooks/useAdaptivity' ;
55import { useMergeProps } from '../../../hooks/useMergeProps' ;
6- import { onLabelClickWrapper } from '../../../lib/onLabelClickWrapper ' ;
6+ import { withLabelClickWrapper } from '../../../lib/withLabelClickWrapper ' ;
77import { Tappable } from '../../Tappable/Tappable' ;
88import type { CheckboxProps } from '../Checkbox' ;
99import { CheckboxInput } from '../CheckboxInput/CheckboxInput' ;
@@ -95,7 +95,7 @@ export function CheckboxSimple({
9595 hasActive = { hasActive }
9696 focusVisibleMode = { focusVisibleMode }
9797 Component = "label"
98- onClick = { onLabelClickWrapper ( onClick ) }
98+ onClick = { withLabelClickWrapper ( onClick ) }
9999 { ...rootRest }
100100 >
101101 < CheckboxInput
Original file line number Diff line number Diff line change 33import * as React from 'react' ;
44import { classNames } from '@vkontakte/vkjs' ;
55import { useMergeProps } from '../../hooks/useMergeProps' ;
6- import { onLabelClickWrapper } from '../../lib/onLabelClickWrapper' ;
76import { warnOnce } from '../../lib/warnOnce' ;
7+ import { withLabelClickWrapper } from '../../lib/withLabelClickWrapper' ;
88import type { HasDataAttribute , HasRootRef } from '../../types' ;
99import { SelectionControl } from '../SelectionControl/SelectionControl' ;
1010import { SelectionControlLabel } from '../SelectionControl/SelectionControlLabel/SelectionControlLabel' ;
@@ -148,7 +148,7 @@ export const Radio = ({
148148 hasActive = { hasActive }
149149 focusVisibleMode = { focusVisibleMode }
150150 disabled = { inputRest . disabled }
151- onClick = { onLabelClickWrapper ( onRootClick ) }
151+ onClick = { withLabelClickWrapper ( onRootClick ) }
152152 { ...rootRest }
153153 >
154154 < RadioInput slotProps = { { input : inputRest } } />
Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ import { useFocusVisibleClassName } from '../../hooks/useFocusVisibleClassName';
99import { useMergeProps } from '../../hooks/useMergeProps' ;
1010import { usePlatform } from '../../hooks/usePlatform' ;
1111import { callMultiple } from '../../lib/callMultiple' ;
12- import { onLabelClickWrapper } from '../../lib/onLabelClickWrapper' ;
1312import { warnOnce } from '../../lib/warnOnce' ;
13+ import { withLabelClickWrapper } from '../../lib/withLabelClickWrapper' ;
1414import type { HasDataAttribute , HasRootRef } from '../../types' ;
1515import { RootComponent } from '../RootComponent/RootComponent' ;
1616import { VisuallyHidden , type VisuallyHiddenProps } from '../VisuallyHidden/VisuallyHidden' ;
@@ -172,7 +172,7 @@ export const Switch = ({
172172 isRtl && styles . rtl ,
173173 focusVisibleClassNames ,
174174 ) }
175- onClick = { onLabelClickWrapper ( onRootClick ) }
175+ onClick = { withLabelClickWrapper ( onRootClick ) }
176176 { ...rootRest }
177177 >
178178 < VisuallyHidden baseClassName = { styles . inputNative } { ...inputProps } />
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import type * as React from 'react' ;
2+
3+ export const withLabelClickWrapper = (
4+ onClick ?: React . MouseEventHandler < HTMLLabelElement > ,
5+ ) : React . MouseEventHandler < HTMLLabelElement > | undefined => {
6+ if ( onClick ) {
7+ return ( event ) => {
8+ if ( ( event . target as HTMLElement ) . tagName === 'INPUT' ) {
9+ onClick ( event ) ;
10+ }
11+ } ;
12+ }
13+ return undefined ;
14+ } ;
You can’t perform that action at this time.
0 commit comments