Skip to content

feat(input): add input-password-toggle component - #29175

Merged
liamdebeasi merged 47 commits into
feature-8.0from
ld/password-toggle
Mar 25, 2024
Merged

feat(input): add input-password-toggle component#29175
liamdebeasi merged 47 commits into
feature-8.0from
ld/password-toggle

Conversation

@liamdebeasi

@liamdebeasiliamdebeasi commented Mar 18, 2024

Copy link
Copy Markdown
Contributor

Issue number: Internal


What is the current behavior?

When given a password input it is hard to know what users are typing as the contents of the input are obscured. As a result, it is a common pattern to have a button that lets users temporarily toggle the visibility of the password so they can correct any mistakes. Ionic currently has the infrastructure for developers to implement this on their own, but this use case is so common that the team thinks it is worth having this functionality built-in to Ionic.

What is the new behavior?

  • Introduces the ion-input-password-toggle component. This component is a button that toggles the visibility of the text in the input it is slotted into.

Does this introduce a breaking change?

  • Yes
  • No

Other information

⚠️ Give co-author credit to #29141 on merge.

Docs PR: ionic-team/ionic-docs#3541

Note: We did not do the approach listed in the other PR due to #29141 (comment).

@github-actionsgithub-actionsBot added the package: core @ionic/core package label Mar 18, 2024
@github-actionsgithub-actionsBot added package: angular @ionic/angular package package: vue @ionic/vue package package: react @ionic/react package labels Mar 19, 2024
@liamdebeasiliamdebeasi changed the title Ld/password togglefeat(input): add input-password-toggle componentMar 19, 2024
Base automatically changed from ld/input-slot-margin to feature-8.0March 19, 2024 17:36
Comment threadcore/src/components/input-password-toggle/input-password-toggle.tsx Outdated
Comment threadcore/src/components/input/input.tsx Outdated
Comment threadcore/src/components/input-password-toggle/input-password-toggle.ios.scss Outdated
Comment threadcore/src/components/input-password-toggle/input-password-toggle.tsx Outdated
liamdebeasi added a commit that referenced this pull request Mar 21, 2024
Issue number: Internal
---------
<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->
<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->
## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->
[Amanda pointed out that the ripple effect for the Button inside of
InputPasswordToggle was not
working](#29175 (comment)).
I found out that calling `ev.preventDefault` on `pointerdown` causes
`mouseup` to not get fired. On desktop, we rely on `mouseup` to know
when to add the ripple effect. (`touchend` is not impacted)
Interestingly, calling `ev.preventDefault` on `pointerdown` does **not**
prevent `pointerup` from being fired. The idea here is that if we
migrate the tap click utility to use the PointerEvents API instead of
separate mouse/touch listeners we can keep the existing tap click
behavior while also fixing the bug that Amanda noted.
## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->
- Tap click nows listens for the Pointer Events instead of separate
mouse/touch events
Impact to developers is fairly minimal. There should be no behavior
change (other than the bug I noted being fixed). There should be a very
small perf boost because this util now only adds 4 event listeners on
the document instead of 7 previously.
## Does this introduce a breaking change?
- [ ] Yes
- [x] No
<!--
If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer
for more information.
-->
## Other information
<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
Reviewers: Please manually test this on desktop devices as well as iOS
and Android devices (not Chrome Dev Tools. iOS simulators are fine).
Test that components such as `ion-button` correctly add the activated
state (or ripple effect for MD). Also verify that the activated state is
not added when tapping the button and then scrolling. For desktop, check
that right clicking does not add the activated state.

@averyrousseauaveryrousseau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We discussed the possibility of using the new round button styles in #29161 instead of needing a shadow part to style the new button, but I don't see that as a blocker 👍

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This is correct. The team made this screenshot update in next but it never made its way into feature-8.0

@liamdebeasi
liamdebeasi merged commit 6c500fd into feature-8.0Mar 25, 2024
@liamdebeasi
liamdebeasi deleted the ld/password-toggle branch March 25, 2024 17:22
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: angular@ionic/angular packagepackage: core@ionic/core packagepackage: react@ionic/react packagepackage: vue@ionic/vue package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@liamdebeasi@brandyscarney@thetaPC@sean-perkins@averyrousseau@Ionitron