Skip to content
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

Merged
merged 6 commits into from
Feb 29, 2024

Conversation

ibolton336
Copy link
Member

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

@ibolton336 ibolton336 added the cherry-pick/release-0.3 This PR should be cherry-picked to release-0.3 branch. label Feb 28, 2024
Copy link
Member

@sjd78 sjd78 left a 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".

Comment on lines +52 to +57
React.useEffect(() => {
setSelectOptions(
Array.isArray(category.selectOptions) ? category.selectOptions : []
);
}, [category.selectOptions]);

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

@ibolton336 ibolton336 merged commit d346801 into konveyor:main Feb 29, 2024
6 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 29, 2024
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]>
ibolton336 added a commit that referenced this pull request Feb 29, 2024
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick/release-0.3 This PR should be cherry-picked to release-0.3 branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants