-
Notifications
You must be signed in to change notification settings - Fork 126
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
Update _RenderFormInput.tsx featue Ehancement #67
Changes from 1 commit
ed63b26
34d244e
777b172
2179048
8d71754
1adf8d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -28,6 +28,7 @@ | |||||
onChange, | ||||||
} = useExtendRenderFormInputProps(props); | ||||||
const { _ } = useLingui(); | ||||||
const isPasswordReveal = useToggle(); | ||||||
const formProps = { | ||||||
label, | ||||||
required, | ||||||
|
@@ -70,10 +71,37 @@ | |||||
|
||||||
switch (type) { | ||||||
case "email": | ||||||
case "password": | ||||||
case "url": | ||||||
case "color": | ||||||
return <FormInput type={type} {...formProps} />; | ||||||
case "password": | ||||||
return ( | ||||||
<FormInput | ||||||
type={isPasswordReveal.isOn ? "text" : "password"} | ||||||
{...formProps} | ||||||
rightActions={ | ||||||
formProps.input.value | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned above the logic of the rightAction always be present and should be based on the rightActions: [showPassword.isOn ? {
systemIcon: 'EyeOff',
action: showPassword.toggle,
label: msg`Hide Password`,
}: {
systemIcon: 'Eye',
action: showPassword.toggle,
label: msg`Show Password`,
}] |
||||||
? [ | ||||||
{ | ||||||
systemIcon: "Eye", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add this
to |
||||||
action: () => { | ||||||
isPasswordReveal.toggle(); | ||||||
}, | ||||||
label: msg`show Password`, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}, | ||||||
] | ||||||
: [] | ||||||
} | ||||||
input={{ | ||||||
...formProps.input, | ||||||
onChange: (val) => { | ||||||
formProps.input.onChange(val); | ||||||
if (!formProps.input.value) isPasswordReveal.off(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The switch should be intentional not hooked to the onChange handler |
||||||
}, | ||||||
}} | ||||||
/> | ||||||
); | ||||||
|
||||||
case "number": | ||||||
return <FormNumberInput {...formProps} />; | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this to a new component,
FormPasswordInput
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay sir