ArturAronov
ArturAronov
SSolidJS
Created by ArturAronov on 8/7/2023 in #support
input loosing focus after each key press
Hello. I have a bug that's been bothering me for couple of days now to which I can't find any solution... Every time when I press the key in input, the text field automatically loses focus.
const [inputAnswers, setInputAnswers] = createStore<Array<string>>(
["answer1", "answer2", "answer3"]
);
const [inputAnswers, setInputAnswers] = createStore<Array<string>>(
["answer1", "answer2", "answer3"]
);
<AnswerForm
answers={inputAnswers}
onUpdateAnswer={setInputAnswers}
/>
<AnswerForm
answers={inputAnswers}
onUpdateAnswer={setInputAnswers}
/>
AnswerForm.tsx
<For each={props.answers} fallback={""}>
{(answer, index) => {
return (
<input
type="text"
value={answer}
onInput={(e) =>
props.onUpdateAnswer(index(), e.currentTarget.value)
}
/>
)}}
</For>
<For each={props.answers} fallback={""}>
{(answer, index) => {
return (
<input
type="text"
value={answer}
onInput={(e) =>
props.onUpdateAnswer(index(), e.currentTarget.value)
}
/>
)}}
</For>
Thank you for your help in advance.
6 replies