You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: IonInput type="password" clears input field on modifier key press #28633
I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v7.x
Current Behavior
When IonInput is given a value of type="password" in @ionic/react, the input will clear text unexpectedly when certain keys are pressed. This is most notable when using a keyboard to navigate between controls. This behavior is not observed with the native input element with type set to password or the default IonInput.
Expected Behavior
IonInputs should be accessible via keyboard. Pressing modifier keys (e.g., shift, command) should not clear a password input (unless combined with another key, e.g., shift + p).
Steps to Reproduce
Create an IonInput with type="password"
Enter a value (either via keyboard or via password manager autofill)
cordova-res : not installed
native-run : not installed
System:
NodeJS : v18.18.0
npm : 9.4.2
OS : Linux 5.0
Additional Information
First noticed on a project using @ionic/react: 7.0.4 and validated on latest available release in StackBlitz (i.e., "@ionic/react": "^7.5.7" and "@ionic/react-router": "^7.5.7").
Thanks for the report. We had a partial fix in Ionic 7.3.1 which accounts for going from a password input to a non-password input, but we forgot to account for the Shift key modifier. I'll work on a fix for this.
Actually it looks like we do not account for several keys including "Control", "Meta", and "Shift". The problem here is the Shift key gets dispatched first when tabbing backwards. Since Shift is not explicitly excluded, the input gets cleared.
Worth noting that your demo was using Ionic 7.0.10 (the package-lock.json had that specified), so you did not have the 7.3.1 fix. However, there are other edge cases we need to fix too.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Activity
liamdebeasi commentedon Dec 5, 2023
Thanks for the report. We had a partial fix in Ionic 7.3.1 which accounts for going from a password input to a non-password input, but we forgot to account for the Shift key modifier. I'll work on a fix for this.
liamdebeasi commentedon Dec 5, 2023
Actually it looks like we do not account for several keys including "Control", "Meta", and "Shift". The problem here is the Shift key gets dispatched first when tabbing backwards. Since Shift is not explicitly excluded, the input gets cleared.
Worth noting that your demo was using Ionic 7.0.10 (the
package-lock.jsonhad that specified), so you did not have the 7.3.1 fix. However, there are other edge cases we need to fix too.chawes13 commentedon Dec 5, 2023
@liamdebeasi huh, weird. Guess I need to file a Stackblitz issue now 😅 . Sorry about that!
liamdebeasi commentedon Dec 5, 2023
Here's a dev build if you are interested in testing the proposed fix:
7.5.8-dev.11701791090.18ebbea8Install Example:
fix(input, textarea): clearOnInput ignores key modifiers (#28639)
ionitron-bot commentedon Jan 10, 2024
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.