Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashing Select component #3627

Merged
merged 2 commits into from
Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/select/src/components/query-list/queryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,6 @@ export function getFirstEnabledItem<T>(
if (!isItemDisabled(items[index], index, itemDisabled)) {
return items[index];
}
} while (index !== startIndex);
} while (index !== startIndex && startIndex !== -1);
return null;
}
8 changes: 8 additions & 0 deletions packages/select/test/selectComponentSuite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ export function selectComponentSuite<P extends IListItemsProps<IFilm>, 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 });
Expand Down