Skip to content

Commit

Permalink
fix(dashboard): clear selected properties on asset change
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbuss authored and diehbria committed Dec 5, 2023
1 parent 71a0b29 commit 05f0374
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import { useSelector } from 'react-redux';
import { isFunction } from 'lodash';
import { type IoTSiteWiseClient } from '@aws-sdk/client-iotsitewise';
Expand Down Expand Up @@ -80,6 +80,20 @@ export function ModeledDataStreamTable({
}
);

/**
* Reset selected items if the user changes the asset
* to avoid confusing add UX
*/
useEffect(() => {
actions.setSelectedItems([]);
/**
* adding actions as a dependency causes
* the hook to run on every change becuase useCollection
* returns a new action reference
*/
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedAsset]);

const handleClickNextPage = () => {
if (isFunction(onClickNextPage)) {
onClickNextPage();
Expand Down

0 comments on commit 05f0374

Please sign in to comment.