-
Notifications
You must be signed in to change notification settings - Fork 32
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
RHSTOR-7003: Disaster recovery UI for Kubevirt VM - Discovered(Standalone) #1889
base: master
Are you sure you want to change the base?
RHSTOR-7003: Disaster recovery UI for Kubevirt VM - Discovered(Standalone) #1889
Conversation
@GowthamShanmugam: This pull request references RHSTOR-7003 which is a valid jira issue. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: GowthamShanmugam The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
334d261
to
9723003
Compare
@GowthamShanmugam: This pull request references RHSTOR-7003 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
9723003
to
91ab186
Compare
91ab186
to
f65587a
Compare
f65587a
to
5630f8e
Compare
7250785
to
ef83318
Compare
f2ecf9c
to
0226a85
Compare
packages/mco/components/modals/app-manage-policies/app-manage-policies-modal.tsx
Outdated
Show resolved
Hide resolved
packages/mco/components/modals/app-manage-policies/parsers/discovered-vm-parser.tsx
Outdated
Show resolved
Hide resolved
packages/shared/src/input-with-requirements/nameInputWithValidation.tsx
Outdated
Show resolved
Hide resolved
React.useEffect(() => { | ||
onChange(isValid ? newName : ''); | ||
}, [isValid, name, onChange, newName]); |
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.
textInputProps
has a onChange
prop, do we need useEffect
explicitly ?? Can we try using textInputProps
's onChange
instead.
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.
what's the use of this useEffect
?? Why do we want to automatically reset the name if it's invalid ??
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.
The design of TextInputWithFieldRequirements
relies on receiving the TextInput
value from the watch
function, which is why useEffect
is used throughout. It resets to an empty value intentionally to prevent the user from moving to the next wizard step, as the validation requires name !== ''
.
However, this reset doesn’t clear the already typed text in the input box(its a separate state) — it only returns an empty value to the caller.
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.
I got your point that other places are using useEffect
as well, but they are just misusing the hook... a generic component should not make same mistake again... instead of useEffect
u can utilise the onChange
prop...
check: https://github.com/red-hat-storage/odf-console/blob/master/packages/odf/components/attach-storage-storagesystem/storageclass-form.tsx#L252-L257
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.
got it, i will change to this and I will change the onChange function
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.
I reviewed this logic. The val is compared with isValid before the new val is fully validated, meaning isValid may still hold an outdated result. Only after the state updates does isValid refresh, but by then, the state value is already set incorrectly.
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.
ack !!
React.useEffect(() => { | ||
onChange(isValid ? newName : ''); | ||
}, [isValid, name, onChange, newName]); |
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.
this change doesn't seems like something which should be part of shared
component...
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.
it will work for all, #1889 (comment)
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.
name.input.validation.mp4
packages/shared/src/input-with-requirements/nameInputWithValidation.tsx
Outdated
Show resolved
Hide resolved
React.useEffect(() => { | ||
onChange(isValid ? newName : ''); | ||
}, [isValid, name, onChange, newName]); |
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.
make sure ref of onChange
is stable if we are adding it to the dep list of the hook...
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.
i added useRef for onChange, please check
0226a85
to
c7d232a
Compare
d46ed8b
to
62b4753
Compare
Signed-off-by: Gowtham Shanmugasundaram <[email protected]>
62b4753
to
4021523
Compare
On top of: #1856