Fix dropdown negative wraparound for keyboard accessibility

This commit is contained in:
Michael Telatynski 2021-08-06 14:21:56 +01:00
parent 54fb24f359
commit 7a11279682

View file

@ -269,7 +269,7 @@ export default class Dropdown extends React.Component<IProps, IState> {
private prevOption(optionKey: string): string {
const keys = Object.keys(this.childrenByKey);
const index = keys.indexOf(optionKey);
return keys[(index - 1) % keys.length];
return keys[index <= 0 ? keys.length - 1 : (index - 1) % keys.length];
}
private scrollIntoView(node: Element) {