File tree 2 files changed +5
-15
lines changed
2 files changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -220,18 +220,14 @@ function up(
220
220
221
221
const canClick = pointerType !== 'mouse' || button === 'primary'
222
222
if ( canClick && target === pressed . downTarget ) {
223
- fire ( 'click' )
223
+ const unpreventedClick = fire ( 'click' )
224
224
if ( clickCount === 2 ) {
225
225
fire ( 'dblclick' )
226
226
}
227
227
228
- // If the click happens inside a `label` with a control, the control (or closes focusable) is focused.
229
- const label = target . closest ( 'label' )
230
- if ( label ?. control ) {
231
- focus (
232
- findClosest ( label . control , isFocusable ) ??
233
- target . ownerDocument . body ,
234
- )
228
+ const control = target . closest ( 'label' ) ?. control
229
+ if ( unpreventedClick && control && isFocusable ( control ) ) {
230
+ focus ( control )
235
231
}
236
232
}
237
233
}
Original file line number Diff line number Diff line change @@ -319,10 +319,6 @@ describe('focus control when clicking label', () => {
319
319
320
320
expect ( label ) . not . toHaveFocus ( )
321
321
expect ( input ) . toHaveFocus ( )
322
- expect ( input ) . toHaveProperty ( 'selectionStart' , 0 )
323
-
324
- // TODO: click on label selects input value
325
- // expect(input).toHaveProperty('selectionEnd', 3)
326
322
} )
327
323
328
324
test ( 'click handlers can prevent moving focus per label' , async ( ) => {
@@ -333,9 +329,7 @@ describe('focus control when clicking label', () => {
333
329
334
330
await userEvent . pointer ( { keys : '[MouseLeft]' , target : label } )
335
331
336
- // TODO: honor click handler
337
- // expect(input).not.toHaveFocus()
338
- expect ( input ) . toBeTruthy ( )
332
+ expect ( input ) . not . toHaveFocus ( )
339
333
} )
340
334
341
335
test ( 'do not move focus to disabled control' , async ( ) => {
You can’t perform that action at this time.
0 commit comments