Skip to content

Commit

Permalink
Merge pull request #319 from visdesignlab/isu306-trrack-filter-dups
Browse files Browse the repository at this point in the history
Bugfix: no Trrack action for unchanged filters
  • Loading branch information
NateLanza authored Mar 25, 2024
2 parents 3f44d6c + 725d44d commit cb64fb6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/upset/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export const Sidebar = () => {
);

const [degreeFilters, setDegreeFilters] = useState([minVisible, maxVisible]);
// Tracking the previous state of the filters to avoid unnecessary updates
const [prevFilters, setPrevFilters] = useState([minVisible, maxVisible]);

useEffect(() => {
if (firstAggregateBy === 'None') {
Expand Down Expand Up @@ -286,8 +288,14 @@ export const Sidebar = () => {
}
}}
onChangeCommitted={() => {
actions.setMinVisible(degreeFilters[0]);
actions.setMaxVisible(degreeFilters[1]);
// Prevents unncessary Trrack state changes
if (prevFilters[0] !== degreeFilters[0]) {
actions.setMinVisible(degreeFilters[0]);
}
if (prevFilters[1] !== degreeFilters[1]) {
actions.setMaxVisible(degreeFilters[1]);
}
setPrevFilters(degreeFilters);
}}
/>
</Box>
Expand Down

0 comments on commit cb64fb6

Please sign in to comment.