|
@@ -41,6 +41,17 @@ export const SearchForm = (props: Props): JSX.Element => {
|
|
|
[searchKeyword, onSubmit],
|
|
[searchKeyword, onSubmit],
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ // Prevent Downshift from intercepting Home/End keys so they move
|
|
|
|
|
+ // the cursor within the input field instead of navigating the list
|
|
|
|
|
+ const keyDownHandler = useCallback(
|
|
|
|
|
+ (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
|
|
|
+ if (e.key === 'Home' || e.key === 'End') {
|
|
|
|
|
+ e.nativeEvent.preventDownshiftDefault = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ [],
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
const inputOptions = useMemo(() => {
|
|
const inputOptions = useMemo(() => {
|
|
|
return getInputProps({
|
|
return getInputProps({
|
|
|
type: 'text',
|
|
type: 'text',
|
|
@@ -49,8 +60,9 @@ export const SearchForm = (props: Props): JSX.Element => {
|
|
|
ref: inputRef,
|
|
ref: inputRef,
|
|
|
value: searchKeyword,
|
|
value: searchKeyword,
|
|
|
onChange: changeSearchTextHandler,
|
|
onChange: changeSearchTextHandler,
|
|
|
|
|
+ onKeyDown: keyDownHandler,
|
|
|
});
|
|
});
|
|
|
- }, [getInputProps, searchKeyword, changeSearchTextHandler]);
|
|
|
|
|
|
|
+ }, [getInputProps, searchKeyword, changeSearchTextHandler, keyDownHandler]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (inputRef.current != null) {
|
|
if (inputRef.current != null) {
|