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

frontend: Rewrite useQueryParamsState logic and add unit tests #2600

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sniok
Copy link
Contributor

@sniok sniok commented Nov 22, 2024

How to test:

Go to map
Select a node
Refresh the page
Node should still be selected

Before this fix it wouldn't work

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Nov 22, 2024
@sniok sniok requested a review from a team November 25, 2024 12:41
Comment on lines 26 to 28
if (initialState) {
return initialState;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU, if the initialState is valid, this logic will never actually get the param from the URL if it has an initialState. Is this intended?
Shouldn't we keep the whole logic but return the initialState instead of undefined at the end of this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just retested it and namespace default grouping is not working properly. returning initialState at the end instead of undefined doesn't work because there's a useEffect that updates the value from existing url state. I need to rethink this logic more

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rewrote the logic to get rid of useState and it's so much simpler now. also added unit tests

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Nov 27, 2024
@sniok sniok changed the title frontend: Fix initial state in useQueryParamsState frontend: Rewrite useQueryParamsState logic and add unit tests Nov 27, 2024
@sniok sniok added bug Something isn't working frontend Issues related to the frontend labels Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend Issues related to the frontend size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Development

Successfully merging this pull request may close these issues.

2 participants