ionic-team / ionic-team/ionic-framework

bug: React Hoof Forms/Ionic React: Fulfilling input value automatically based on input value tilting

オープン
#22,718 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
package: react type: bug
主要言語
TypeScript
スター
52.7k
フォーク
13.3k
平均マージ
1日 15時間
マージ済み PR(30日)
51

説明

# Bug Report

**Ionic version:**

[ ] **4.x**
[x] **5.5.2**

**Current behavior:**

![Screen Recording 2020-12-24 at 18 50 41](https://user-images.githubusercontent.com/5034215/103134835-28af2280-46c5-11eb-9705-561c386f7ea0.gif)

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:
```tsx






Cash Amount


setValue(
"posValue",
calculateFieldValue(e.detail.value)
)
}
required
/>
{errors?.cashValue && (

)}



POS Amount


setValue(
"cashValue",
calculateFieldValue(e.detail.value)
)
}
required
/>
{errors?.posValue && (

)}




{packageDetails?.orderData?.currencySymbol}
{packagePrice}


Pay





```

It was working also with this other code:
```tsx
const [formChangeFieldName, setFormChangeFieldName] = useState<'cashAmount' | 'posAmount'>()
const formMethods = useForm();
const { register, watch, errors, handleSubmit } = formMethods;
const { cashAmount, posAmount } = watch()
---
const onChangeInput = (e: any & { target: { name: string } }) => setFormChangeFieldName(e.target.name)
---

---

```
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 launch `setFormChangeFieldName(e.target.name)`.

So, We developed the next code:
```ts


Nakit
(
{
console.log("Firing onChange at Cash!")
setValue("posAmount", calculateFieldValue(e.detail.value!))
// onChange(e.detail.value!)
}}
onIonBlur={onBlur}
required
/>
)}
/>

{formErrorMessage(errors.cashAmount)}


Pos
(
{
console.log("Firing onChange at POS!")
setValue("cashAmount", calculateFieldValue(e.detail.value!))
// onChange(e.detail.value!)
}}
onIonBlur={onBlur}
required
/>
)}
/>

{formErrorMessage(errors.posAmount)}


Ödeme yap


{packageDetails.orderData.currencySymbol}
{packageDetails.orderData.price}



```

**Other information:**

We opened a [question](https://stackoverflow.com/questions/65440610/react-hook-forms-ionic-react-fulfilling-input-value-automatically-based-on-chan) on **StackOverflow** in order to get an answer about this concern.

**Ionic info:**

```
❯ ionic info

Ionic:

Ionic CLI : 6.12.3 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/react 5.5.2

Capacitor:

Capacitor CLI : 2.4.5
@capacitor/core : 2.4.5

Utility:

cordova-res : not installed
native-run : not installed

System:

NodeJS : v15.4.0 (/usr/local/Cellar/node/15.4.0/bin/node)
npm : 7.0.15
OS : macOS Big Sur

```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start by reproducing the reported behavior in an Ionic React app using IonInput, React Hook Form, and Ionic 5.5.2, then inspect the IonInput onIonChange path and the provided controlled-input examples. Done means the change event fires when the input value changes and the paired field updates without breaking form validation.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
react, typescript
領域
frontend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
28/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。