Skip to content

Commit

Permalink
Fix building focusable options from groups (#4399)
Browse files Browse the repository at this point in the history
* Fix building focusable options from groups

* Create happy-years-clap.md

* Add E2E test
  • Loading branch information
Methuselah96 authored Jan 22, 2021
1 parent e7bafee commit 44f285b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-years-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-select": patch
---

Fixed building focusable options from groups
5 changes: 3 additions & 2 deletions cypress/fixtures/selectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"multiSelectDefaultValues": "#multi-select .react-select__multi-value",
"multiSelectInput": "#react-select-multi-select-input",
"placeHolderMulti": "#multi-select .react-select__placeholder",
"toggleMenuMulti": "#multi-select .react-select__dropdown-indicator"
}
"toggleMenuMulti": "#multi-select .react-select__dropdown-indicator",
"focusedOption": ".react-select__option--is-focused"
}
9 changes: 9 additions & 0 deletions cypress/integration/single-select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ describe('Single Select', () => {
.find(selector.groupHeading)
.should('have.length', 2);
});

it(`Should focus next option on down arrow key press: ${viewport}`, () => {
cy.get(selector.singleGroupedSelect)
.click()
.find('input')
.type('{downarrow}', { force: true })
.get(selector.focusedOption)
.should('exist');
});
});

context(`Clearable in view: ${viewport}`, () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-select/src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function buildFocusableOptionsFromCategorizedOptions(
) {
return categorizedOptions.reduce((optionsAccumulator, categorizedOption) => {
if (categorizedOption.type === 'group') {
optionsAccumulator.push(...categorizedOption.options);
optionsAccumulator.push(...categorizedOption.data.options);
} else {
optionsAccumulator.push(categorizedOption.data);
}
Expand Down

0 comments on commit 44f285b

Please sign in to comment.