Skip to content

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

@decause-gov

Description

@decause-gov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions