[Bug]: PasswordInput - onTogglePasswordVisibility handler returns multiple elements #15600
Closed
2 tasks done
Labels
adopter: strategic-product
Work-stream that directly effects the Product-led Growth initiative.
status: needs triage 🕵️♀️
type: bug 🐛
Package
@carbon/react
Browser
Chrome, Firefox
Package version
v11.48.0
React version
v18.2.0
Description
The
onTogglePasswordVisibility
handler is returning the exact element being clicked on rather than just the button or some other useful state object/prop.PasswordInput
packages/react/src/components/TextInput/PasswordInput.tsx
Expected to receive just the button element.
The doc comment and return type for the prop seems to indicate it should just be button:
Exact element clicked is returned (e.g. svg, path, button).
It's not clear what the utility of receiving any click event is here (What would a user do with this information?). Personally, I thought it would give me the ability to override the default behavior which simply toggles the input type. Perhaps receiving the current input type would be passed back. Example:
Reproduction/example
https://stackblitz.com/edit/github-q71nkn?file=src%2FApp.jsx
Steps to reproduce
Add this line:
onTogglePasswordVisibility={(e) => console.log(e.target)} // <--- This line
to the
TogglePasswordVisibility
component in the story:packages/react/src/components/TextInput/TextInput.stories.js
Like so:
Check the console and click on various spots on the visibility toggle. Observe the behavior as shown in video below.
Screen.Recording.2024-01-24.at.2.06.51.PM.mov
Suggested Severity
Severity 3 = User can complete task, and/or has a workaround within the user experience of a given component.
Application/PAL
Turbonomic
Code of Conduct
The text was updated successfully, but these errors were encountered: