Skip to content

Prevent disabled Inputs from being edited #8238

Closed

Description

@nickofthyme

Describe the bug
When using LastPass or similar password management tools. Eui does not prevent these tools from editing disabled input values. This results in edited disabled values being saved. However, applying readonly does block the input value from being updated.

Environment and versions

  • EUI version: latest

To Reproduce
Steps to reproduce the behavior:

  1. Create an EuiFieldText input with the name attribute set to 'username'.
  2. Set input to disabled
  3. Download any password manager
  4. Create a password record on the current page
  5. Refresh and fill the input using the password manager.
Zight.Recording.2024-12-13.at.01.45.53.PM.mp4

See demo: https://codesandbox.io/p/sandbox/adoring-christian-jk8t45

Expected behavior
Disabled inputs should never be editable.

Additional context

Attempting to use the solution from https://stackoverflow.com/a/28216951/6943587 does not work. Applying autocomplete="off" to the input and/or form, does not prevent the update of the input value.

Every solution I tried always resulted in the onChange handler being called. The most foolproof solution is to set readOnly whenever disabled is set, unless overridden by the user.

Activity

  1. changed the title [-]Prevent `readonly` and `disabled` Inputs from being edited[/-] [+]Prevent `disabled` Inputs from being edited[/+] on Dec 15, 2024
  2. added
    low hanging fruit
    on Dec 17, 2024
  3. self-assigned this
    on Jan 14, 2025
  4. tkajtoch commented on Apr 25, 2025

    @tkajtoch
    Contributor

    Hey @nickofthyme is this still needed considering the changes we did in #8239?

  5. nickofthyme commented on Apr 25, 2025

    @nickofthyme
    ContributorAuthor

    Yeah thanks, I forgot why I opened 2 issues but setting readonly to the value of disabled by default in #8271, fixes this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

low hanging fruit

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions