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 11, 2019
1 parent d2722ca commit 2809765
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 @@ -50,7 +50,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 2809765

Please sign in to comment.