-
Notifications
You must be signed in to change notification settings - Fork 1
Create overlapping filter options #82
Description
Current behavior:
A user clicks on a filter option (e.g. Day 1), and the video list updates with videos that match that criteria. A user then clicks on a different type of filter option (e.g. Breakroom), and then the video list updates with videos that match the new criteria.
Desired behavior:
When a user selects a different category of filter option, it does not remove the currently applied filter.
Reason for current behavior:
In the initial filter implementation, a single piece of state is used, filteredVideos, which is initially set to the variable data (an array of objects with video data) from the pageContext object that is used to dynamically generate video pages. When the applyFilter function is triggered when a user clicks on a filter option, it loops through the data array, and pushes objects to the filteredData variable that match the filter criteria. The filteredVideos state is then updated with the filteredData array.
Solution to achieve desired behavior:
- Track additional state. When applying a filter it should be known whether a particular filter type has been applied, and whether that filter type's filter results need to be updated.
- Have the filter function loop through the
filteredVideosstate rather than thedatavariable from which it derives.