Skip to content

Commit

Permalink
Merge pull request #162 from kpi-ua/fix/input-field-types
Browse files Browse the repository at this point in the history
fix: trying to fix search typings
  • Loading branch information
ernado-x authored Feb 15, 2024
2 parents ea45860 + db8764e commit b09f5e8
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/components/InputField/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ const InputField: React.FC<Props> = ({

const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement | HTMLDivElement>) => {
if (e.key === 'Enter') {
const title = e.target.title || '';
handleTipClick(title);
onSubmit && onSubmit(title);
handleTipClick(userInput);
onSubmit && onSubmit(userInput);
}

if (e.key === 'ArrowDown') {
Expand All @@ -97,19 +96,19 @@ const InputField: React.FC<Props> = ({
if (currentFocused === -1) {
if (focusableTips.length) {
setCurrentFocused(0);
focusableTips[0].focus();
(focusableTips[0] as HTMLElement).focus();
}
}

if (currentFocused === focusableTips.length - 1) {
setCurrentFocused(0);
focusableTips[0].focus();
(focusableTips[0] as HTMLElement).focus();
return;
}

setCurrentFocused((prevState) => {
const el = focusableTips[prevState + 1];
el && el.focus();
el && (el as HTMLElement).focus();
return prevState + 1;
});
}
Expand All @@ -121,7 +120,7 @@ const InputField: React.FC<Props> = ({
if (currentFocused === 0) {
setCurrentFocused(() => {
const el = focusableTips[focusableTips.length - 1];
el && el.focus();
el && (el as HTMLElement).focus();
return focusableTips.length - 1;
});

Expand All @@ -130,7 +129,7 @@ const InputField: React.FC<Props> = ({

setCurrentFocused((currentFocus) => {
const el = focusableTips[currentFocus - 1];
el && el.focus();
el && (el as HTMLElement).focus();
return currentFocus - 1;
});
}
Expand Down

0 comments on commit b09f5e8

Please sign in to comment.