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

Front-end: Examine Select-all Behavior in FacilitiesMultiSelect.js #33

Open
Tracked by #42
decause-gov opened this issue Sep 1, 2023 · 0 comments
Open
Tracked by #42
Labels

Comments

@decause-gov
Copy link
Contributor

Issue Report

Front-end: Examine Select-all Behavior in FacilitiesMultiSelect.js

Expected behavior

Behavior could be as expected, but worth examining for possible performance improvements.

Actual behavior

src/components/FacilitiesMultiSelect.js

  1. Inside the useEffect, you are checking the length of facilities against the length of
    selected facilities to determine if "Select All" should be on or off. In this case, the
    selectedFacilities dependency could potentially cause frequent re-renders.

  2. The code block: selectedFacilities.indexOf(id) > -1 inside the map function
    can be performance-intensive if there are many facilities since indexOf would be O(n).

  3. The "Select All" option toggles the state, which means if all facilities are already selected
    and a user clicks "Select All" again, it will deselect all. If this is the desired behavior, it's
    okay. If not, you might want to address it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant