Skip to content

Commit

Permalink
DOM: Avoid consolidating unnamed radio inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Mar 15, 2019
1 parent 19055b2 commit 7f9bbda
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/dom/src/tabbable.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function createStatefulCollapseRadioGroup() {
const { nodeName, type, checked, name } = element;

// For all non-radio tabbables, construct to array by concatenating.
if ( nodeName !== 'INPUT' || type !== 'radio' ) {
if ( nodeName !== 'INPUT' || type !== 'radio' || ! name ) {
return result.concat( element );
}

Expand Down
24 changes: 24 additions & 0 deletions packages/dom/src/test/tabbable.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,29 @@ describe( 'tabbable', () => {
thirdRadio,
] );
} );

it( 'not consolidate unnamed radio inputs', () => {
const node = createElement( 'div' );
const firstRadio = createElement( 'input' );
firstRadio.type = 'radio';
firstRadio.value = 'firstRadio';
const text = createElement( 'input' );
text.type = 'text';
text.name = 'b';
const secondRadio = createElement( 'input' );
secondRadio.type = 'radio';
secondRadio.value = 'secondRadio';
node.appendChild( firstRadio );
node.appendChild( text );
node.appendChild( secondRadio );

const tabbables = find( node );

expect( tabbables ).toEqual( [
firstRadio,
text,
secondRadio,
] );
} );
} );
} );

0 comments on commit 7f9bbda

Please sign in to comment.