Open SalahAdDin opened 3 years ago
Thanks for the issue! This issue has been labeled as holiday triage
. With the winter holidays quickly approaching, much of the Ionic Team will soon be taking time off. During this time, issue triaging and PR review will be delayed until the team begins to return. After this period, we will work to ensure that all new issues are properly triaged and that new PRs are reviewed.
In the meantime, please read our Winter Holiday Triage Guide for information on how to ensure that your issue is triaged correctly.
Thank you!
I want to do a follow up on this issues, just because it is 7 months old and I also ran into related problem with react-hook-form.
When I type-in and I use the physical keyboard to submit the form, react-hook-form register does not change the input value, so at onSubmit its value is still undefined. It will only update when I lose focus on the input.
Could be a problem with react-hook-form, but using the web native input it works, also with chakra-ui Input it also works.
How to reproduce:
import { IonButton, IonInput } from "@ionic/react";
import { useCallback, useState } from "react";
import { useForm } from "react-hook-form";
const SimpleForm = () => {
const { handleSubmit, register } = useForm();
const [text, setText] = useState("");
const onSubmit = useCallback((data) => {
console.log("data", data);
setText(data.fieldName);
}, []);
return (
<>
<form onSubmit={handleSubmit(onSubmit)}>
<IonInput {...register("fieldName")} placeholder="ionInput react" />
<IonButton type="submit">Submit</IonButton>
{text === undefined ? <p>fieldName is undefined</p> : null}
{text === "" ? <p>fieldName is empty string</p> : null}
{text ? (
<p>
fieldName is {'"'}
{text}
{'"'} string
</p>
) : null}
<ul>
<li>Type anything, do not loose focus and:</li>
<li>
<ul>
<li>Try to submit with the keyboard (physical or virtual)</li>
<li>Try to submit with direct hit at submit button</li>
</ul>
</li>
</ul>
</form>
</>
);
};
export default SimpleForm;
It is all about the onChange happening onBlur and not onChange at all, which is different from web native input.
A collaborator could confirm if it's an issue, I can also create a new issue if it's the case.
Bug Report
Ionic version:
[ ] 4.x [x] 5.5.2
Current behavior:
It is imposible to handle both values when the current's input value is changing.
Expected behavior:
The current input must have a normal behavior while the other input's value changes as the current input's value change.
Steps to reproduce:
Just go to the input and change its value.
Related code:
With the following code it was working fine:
It was working also with this other code:
This was working pretty fine, but after update Ionic to
5.5.2
it stopped to work:onIonChange
is not triggered(ensured by log), avoiding to launchsetFormChangeFieldName(e.target.name)
.So, We developed the next code:
Other information:
We opened a question on StackOverflow in order to get an answer about this concern.
Ionic info: