File tree Expand file tree Collapse file tree 2 files changed +5
-15
lines changed Expand file tree Collapse file tree 2 files changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -220,18 +220,14 @@ function up(
220220
221221 const canClick = pointerType !== 'mouse' || button === 'primary'
222222 if ( canClick && target === pressed . downTarget ) {
223- fire ( 'click' )
223+ const unpreventedClick = fire ( 'click' )
224224 if ( clickCount === 2 ) {
225225 fire ( 'dblclick' )
226226 }
227227
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 )
235231 }
236232 }
237233 }
Original file line number Diff line number Diff line change @@ -319,10 +319,6 @@ describe('focus control when clicking label', () => {
319319
320320 expect ( label ) . not . toHaveFocus ( )
321321 expect ( input ) . toHaveFocus ( )
322- expect ( input ) . toHaveProperty ( 'selectionStart' , 0 )
323-
324- // TODO: click on label selects input value
325- // expect(input).toHaveProperty('selectionEnd', 3)
326322 } )
327323
328324 test ( 'click handlers can prevent moving focus per label' , async ( ) => {
@@ -333,9 +329,7 @@ describe('focus control when clicking label', () => {
333329
334330 await userEvent . pointer ( { keys : '[MouseLeft]' , target : label } )
335331
336- // TODO: honor click handler
337- // expect(input).not.toHaveFocus()
338- expect ( input ) . toBeTruthy ( )
332+ expect ( input ) . not . toHaveFocus ( )
339333 } )
340334
341335 test ( 'do not move focus to disabled control' , async ( ) => {
You can’t perform that action at this time.
0 commit comments