Skip to content

bug: IonInput type="password" clears input field on modifier key press  #28633

Closed

Description

@chawes13

Prerequisites

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

  1. Create an IonInput with type="password"
  2. Enter a value (either via keyboard or via password manager autofill)
  3. Tab to the next focusable element
  4. Tab back to the password input
  5. Tab to the next focusable element
  6. IonInput with type="password" is empty

Code Reproduction URL

https://stackblitz.com/edit/vxete3-yk4b3w?file=src%2Fmain.tsx

Ionic Info

Via StackBlitz:

Ionic:

Ionic CLI : 5.4.16

Utility:

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").

Activity

  1. self-assigned this
    on Dec 5, 2023
  2. liamdebeasi commented on Dec 5, 2023

    @liamdebeasi
    Contributor

    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.

  3. liamdebeasi commented on Dec 5, 2023

    @liamdebeasi
    Contributor

    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.

  4. chawes13 commented on Dec 5, 2023

    @chawes13
    Author

    @liamdebeasi huh, weird. Guess I need to file a Stackblitz issue now 😅 . Sorry about that!

  5. added
    package: core
    type: bug
    on Dec 5, 2023
  6. removed their assignment
    on Dec 5, 2023
  7. liamdebeasi commented on Dec 5, 2023

    @liamdebeasi
    Contributor

    Here's a dev build if you are interested in testing the proposed fix: 7.5.8-dev.11701791090.18ebbea8

    Install Example:

    npm install @ionic/[email protected] @ionic/[email protected]
    
  8. added a commit that references this issue on Dec 11, 2023
    8f7d87c
  9. ionitron-bot commented on Jan 10, 2024

    @ionitron-bot

    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.

  10. locked and limited conversation to collaborators on Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: coretype: bug

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions