Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve behavior of password input field #16011

Merged
merged 6 commits into from
Sep 2, 2022
Merged

Conversation

edmundito
Copy link
Contributor

@edmundito edmundito commented Aug 26, 2022

What

Closes #15922

This makes a number of improvements to how the input password fields behave including:

  • The toggle visibility button now focuses back on the text in the previous cursor location or at the end of the text if it's the first time focusing
  • When the user focuses outside of the component, it hides the information again. This ensures that form submission events always present the sensitive fields as password types.
Screen.Recording.2022-08-25.at.16.37.06.mov

How

Moves the focus management to the container div of the input. In this case, it can see both the input field as well as the button and is able to decide when the element is focused or not.

Did some research on what was the best way to set the cursor and the solution that worked was to set the selection range to the cursor's last spot through selectionStart.

To manage the blur, the container element needs to ensure that neither the button is focused or the input is focused in order to correctly hide the password at the right time. Therefore, a setTimeout is needed to wait for event such as when switching focus from the button back to the input (because the sequence of events is button blur -> input focus)

Tests

  • Clicking on the toggle visibility button will focus on the input in the previous cursor location where it was
  • Clicking outside of the password input while visible will make it invisible
  • When pressing the submit button while focused on the visible password input, the submit handler sees a password input field
  • Updated unit tests

@edmundito edmundito added the area/frontend Related to the Airbyte webapp label Aug 26, 2022
@edmundito edmundito requested a review from a team as a code owner August 26, 2022 13:55
@github-actions github-actions bot added the area/platform issues related to the platform label Aug 26, 2022
if (defaultFocus) {
focusOnInputElement();
}
}, [defaultFocus, focusOnInputElement]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like defaultFocus could just be autofocus={defaultFocus} on the InputComponent below.
It's only set in one place and I don't believe it changes.

@edmundito
Copy link
Contributor Author

cc @natalyjazzviolin

@edmundito edmundito requested review from krishnaglick and a team August 29, 2022 14:44
@edmundito edmundito force-pushed the edmundito/password-input-ux branch from d21c4a7 to d0daa29 Compare September 1, 2022 19:57
@edmundito edmundito merged commit c91385d into master Sep 2, 2022
@edmundito edmundito deleted the edmundito/password-input-ux branch September 2, 2022 14:03
letiescanciano added a commit that referenced this pull request Sep 5, 2022
* master: (47 commits)
  Add email to identify users analytics call (#16327)
  🎉 Source Amazon Ads: improve `config.start_date` validation (#16191)
  Add comments about intermediate state emission (#16262)
  MySQL Source : Standardize spec.json for DB connectors that support log-based CDC replication (#16216)
  MSSQL Source : Standardize spec.json for DB connectors that support log-based CDC replication (#16215)
  Hide a bunch more destination with potential unsecure API access (#16320)
  Skip unit tests when run-tests is false (#16267)
  Hide Destination connections from UI (#16310)
  Add scheduled task to clean up old files from workspace (#16247)
  Source Google Analytics v4: Re-name google analytics connector (#16306)
  🐛 Source Facebook Marketing: remove "end_date" from config if empty value (re-implement #16096) (#16222)
  Fix github action syntax (#16277)
  Re-name google analytics cionnectors (#16287)
  Bump Airbyte version from 0.40.3 to 0.40.4 (#16275)
  Hide ES and Redis destination connectors from Cloud (#16276)
  15700  add tests for PokeAPI (#15701)
  Add ProtocolVersion to StandardDefs (#16237)
  🪟 🔧 🧹 Migrate attempt `bytesSynced` to `totalStats.bytesEmitted` and cleanup `AttemptDetails` component (#16126)
  Improve behavior of password input field (#16011)
  Improve airbyte-metrics support in the Helm chart (#16166)
  ...
robbinhan pushed a commit to robbinhan/airbyte that referenced this pull request Sep 29, 2022
* Improve behavior of password input field

* Show / hide button now focuses back on the text at the previous cursor location
* On comonent blur, it hides the information again

* Fix logic on input blur

* Add hide password on blur test to input

* Clear the input selection start on blur

* Remove defaultFocus and replace with autoFocus
jhammarstedt pushed a commit to jhammarstedt/airbyte that referenced this pull request Oct 31, 2022
* Improve behavior of password input field

* Show / hide button now focuses back on the text at the previous cursor location
* On comonent blur, it hides the information again

* Fix logic on input blur

* Add hide password on blur test to input

* Clear the input selection start on blur

* Remove defaultFocus and replace with autoFocus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change Signup password form field type to password
2 participants