diff --git a/packages/select/src/components/query-list/queryList.tsx b/packages/select/src/components/query-list/queryList.tsx index 4002401cbb..a36d6f4db1 100644 --- a/packages/select/src/components/query-list/queryList.tsx +++ b/packages/select/src/components/query-list/queryList.tsx @@ -587,6 +587,6 @@ export function getFirstEnabledItem( if (!isItemDisabled(items[index], index, itemDisabled)) { return items[index]; } - } while (index !== startIndex); + } while (index !== startIndex && startIndex !== -1); return null; } diff --git a/packages/select/test/selectComponentSuite.tsx b/packages/select/test/selectComponentSuite.tsx index e082a16f4c..f9116f6594 100644 --- a/packages/select/test/selectComponentSuite.tsx +++ b/packages/select/test/selectComponentSuite.tsx @@ -130,6 +130,14 @@ export function selectComponentSuite

, S>( assert.equal((testProps.onActiveItemChange.lastCall.args[0] as IFilm).rank, 20); }); + it("arrow up/down does not invokes onActiveItemChange, when all items are disabled", () => { + const wrapper = render({ ...testProps, itemDisabled: () => true }); + findInput(wrapper).simulate("keydown", { keyCode: Keys.ARROW_DOWN }); + assert.isNull(testProps.onActiveItemChange.lastCall); + findInput(wrapper).simulate("keyup", { keyCode: Keys.ARROW_UP }); + assert.isNull(testProps.onActiveItemChange.lastCall); + }); + it("enter invokes onItemSelect with active item", () => { const wrapper = render(testProps); findInput(wrapper).simulate("keyup", { keyCode: Keys.ENTER });