react-bootstrap-typeahead
Version:
React typeahead with Bootstrap styling
15 lines (14 loc) • 503 B
JavaScript
import isSelectable from './isSelectable';
export default function defaultSelectHint(e, selectHint) {
let shouldSelectHint = false;
if (e.key === 'ArrowRight') {
shouldSelectHint = isSelectable(e.currentTarget)
? e.currentTarget.selectionStart === e.currentTarget.value.length
: true;
}
if (e.key === 'Tab') {
e.preventDefault();
shouldSelectHint = true;
}
return selectHint ? selectHint(shouldSelectHint, e) : shouldSelectHint;
}