-
Notifications
You must be signed in to change notification settings - Fork 43
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
🐛 Load filter values for multiselect before input #1713
Conversation
…onveyor#1702) Resolves https://issues.redhat.com/browse/MTA-2004 <img width="1197" alt="Screenshot 2024-02-27 at 9 59 25 AM" src="https://github.com/konveyor/tackle2-ui/assets/11218376/720d137a-098b-4736-ba1c-b0905073c144"> --------- Signed-off-by: Ian Bolton <[email protected]>
Signed-off-by: Ian Bolton <[email protected]>
1699ba3
to
e6e55eb
Compare
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 PR is really "update the filter values when category.selectOptions
change".
React.useEffect(() => { | ||
setSelectOptions( | ||
Array.isArray(category.selectOptions) ? category.selectOptions : [] | ||
); | ||
}, [category.selectOptions]); | ||
|
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 happen if you just drop saving the "selectOptions" as state? I don't see anywhere in the component's code where the options are better off being held in state instead of just:
const selectOptions = Array.isArray(category.selectOptions) ? category.selectOptions : [];
Worst case you wrap it in a useMemo
, but that wouldn't really even justify the extra cognitive complexity when a string assignment at each render should work just fine.
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.
Need to be able to update the options when the text input changes on line 256.
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.
Ok but still feels awkward. A bigger refactor to rearrange how the component handles input text filtering of the selectOptions could make the data flow easier to track.
Resolves https://issues.redhat.com/browse/MTA-2322 - Need to load the select options into the dropdown state in cases where category.selectOptions is async --------- Signed-off-by: Ian Bolton <[email protected]> Signed-off-by: Cherry Picker <[email protected]>
Resolves https://issues.redhat.com/browse/MTA-2322 - Need to load the select options into the dropdown state in cases where category.selectOptions is async --------- Signed-off-by: Ian Bolton <[email protected]> Signed-off-by: Cherry Picker <[email protected]> Signed-off-by: Ian Bolton <[email protected]> Signed-off-by: Cherry Picker <[email protected]> Co-authored-by: Ian Bolton <[email protected]>
Resolves https://issues.redhat.com/browse/MTA-2322