Skip to content

Commit

Permalink
refresh table on class filter change; #152
Browse files Browse the repository at this point in the history
  • Loading branch information
veeepi committed May 12, 2021
1 parent fc7e0b3 commit becafbb
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/components/TrademarkApplicationPage/GoodsAndServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,31 @@ export default function GoodsAndServices({
const { current: classSearchInstance } = useRef({});
const [loadingClassSearch, setLoadingClassSearch] = useState(false);
useEffect(() => {
// setTermTableData([]);
if (classSearchInstance.delayTimer) {
clearTimeout(classSearchInstance.delayTimer);
}
if (searchClassFilterText === '') {
setLoadingClassSearch(true);
classSearchInstance.delayTimer = setTimeout(() => {
setLoadingClassSearch(false);
setTermTableData([]); // after 0.2 seconds, stop Loading Indicator and apply filter
renderTerms();
}, 200);
}
if (searchClassFilterText !== '') {
setLoadingClassSearch(true);
classSearchInstance.delayTimer = setTimeout(() => {
setLoadingClassSearch(false); // after 1 seconds, stop Loading Indicator and apply filter
setLoadingClassSearch(false); // after 0.6 seconds, stop Loading Indicator and apply filter
setTermTableData([]);
renderTerms();
}, 1000);
}, 600);
} else {
renderTerms();
setLoadingClassSearch(false);
}
}, [searchClassFilterText]);
console.log('searchClassFilterText: ', searchClassFilterText);

const [selectedRow, setSelectedRow] = useState(null); // toggle ListView, detailedView
const [filterSelection, setFilterSelection] = useState(null); // filter termTableResults
Expand Down Expand Up @@ -307,7 +318,7 @@ export default function GoodsAndServices({
}
setInputTo={setSearchTerm}
/>
{termSearchResults.length > 0 && (
{searchTerm.length > 2 && termSearchResults.length > 0 && (
<Box className={classes.niceClassFilterText}>
<Typography>
Each term is associated with a NICE Class
Expand All @@ -322,7 +333,7 @@ export default function GoodsAndServices({
</Box>
)}

{(searchTerm.length > 2 || termTableData.length > 0) &&
{(searchTerm.length > 2 || termSearchResults.length > 0) &&
!loading && (
<>
{termTableData.length > 0 ? (
Expand Down

0 comments on commit becafbb

Please sign in to comment.