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

685: Bug Fix: Selected Panels 'Selected' State #688

Merged
merged 4 commits into from
Jun 10, 2024
Merged

685: Bug Fix: Selected Panels 'Selected' State #688

merged 4 commits into from
Jun 10, 2024

Conversation

jgrimes86
Copy link
Contributor

This addresses issue #685

The selectedPanelKeys state, which controlled the appearance of selected panel filters is not saved when you toggle back and forth between the filter view and property cards view. To keep the panel filters correctly selected after toggling the view, the initial 'selectedPanelKeys' state is now generated from appFilter.

This is an example of the corrected panel filter appearance after toggling between the filter view and property cards view:
image

Copy link

vercel bot commented Jun 8, 2024

@jgrimes86 is attempting to deploy a commit to the Clean and Green Philly Team on Vercel.

A member of the Team first needs to authorize it.

@jgrimes86
Copy link
Contributor Author

@CodeWritingCow I think this PR is one for you to review

@CodeWritingCow CodeWritingCow self-requested a review June 9, 2024 02:27
@CodeWritingCow
Copy link
Collaborator

CodeWritingCow commented Jun 9, 2024

Hi @jgrimes86 I tested your PR in my local env. When I toggle between the filter and property card views, the user's filter choices do persist. However, I encountered two unexpected behaviors:

issue.685.01.mov
  1. Filter count mismatch: For example, if I select all 6 filters in the "Get Access" section, the UI displays the count as 4.
issue.685.02.mov
  1. If I navigate from "Find Properties" page to another page, then back to "Find Properties," then the user's filter choices don't persist. (In other words, the user's selected filters become "unselected.")

Copy link
Collaborator

@CodeWritingCow CodeWritingCow left a comment

Choose a reason for hiding this comment

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

@jgrimes86 can you take a look at the first behavior?

As for the second behavior, it might be caused by an issue unrelated to your current ticket. What do you think?

@jgrimes86
Copy link
Contributor Author

@jgrimes86 can you take a look at the first behavior?

As for the second behavior, it might be caused by an issue unrelated to your current ticket. What do you think?

@CodeWritingCow I've pushed two commits to address both those issues.

For the first behavior, I needed to update filterCount to reflect that three of the 'Get Access' buttons are different values of one 'access_process' filter.

I think the second behaver is related to this ticket in that it is annoying that selected filters don't persist when you're using the website. But it might also be considered unrelated because it is caused by how filter context is saved, not by how the filter context is handled within the side panel components. Fixing that behavior seems to be a pretty straight-forward change, so I made a commit to address that issue also.

The second behavior was happening because the FilterProvider, which provides FilterContext, was only providing context to the 'Find Properties' page components. So when you navigated to one of the other pages, anything stored in state in FilterContext was lost. I've moved FilterProvider into a new FilterProviderWrapper component, modelled after CookieProviderWrapper, and added that to RootLayout. Now you can navigate to another section of the website, and when you go back to 'Find Properties' the filters are still active.

Copy link
Collaborator

@CodeWritingCow CodeWritingCow left a comment

Choose a reason for hiding this comment

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

Hi @jgrimes86 I ran your updated PR locally. You fixed both the first and second issues, and gave a detailed explanation of the second issue. Thanks for going above and beyond.

While the function filterCount fixes the filter count issue, it's getting called multiple times. (See screen recording; I added a console.log for each time that the UI calls filterCount). It'd be more performant if we call it only once or as needed. Otherwise, the rest of the PR looks good.

Can you update the PR so the UI calls filterCount only as needed?

issue.685.03.mov

@jgrimes86
Copy link
Contributor Author

@CodeWritingCow this most recent commit adds a useMemo to filterCount. I have the useMemo looking for changes to appFilter because filterCount needs to reflect changes to appFilter. Unfortunately, appFilter "changes" twice every time a filter is applied (although I can see no difference between those changes), which means that filterCount still gets called several times per filter toggle. But this revision means filterCount isn't called when you first go to the filter view, and I think it halves the amount of times filterCount is called when a filter is toggled.

Video demo of console logs:
https://github.com/CodeForPhilly/clean-and-green-philly/assets/140654473/2f5f971f-bcea-4eab-bca4-8a79ea5ccdbf

@CodeWritingCow
Copy link
Collaborator

CodeWritingCow commented Jun 10, 2024

@jgrimes86 I watched your screen recording and also went over the new commit with useMemo. The changes look good. I'll go ahead and approve this PR. 👍

@CodeWritingCow CodeWritingCow merged commit 8163838 into CodeForPhilly:staging Jun 10, 2024
1 of 2 checks passed
@CodeWritingCow CodeWritingCow added the bug Something isn't working label Jul 26, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants