Skip to content

Commit 13f6cc9

Browse files
committed
fixing loader behaviour
1 parent 4ce9640 commit 13f6cc9

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

  • applications/virtual-fly-brain/frontend/src/components/queryBuilder

applications/virtual-fly-brain/frontend/src/components/queryBuilder/Query.jsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,23 @@ const Query = forwardRef(({ fullWidth, queries, searchTerm }, ref) => {
208208
}, [queries, sortField]);
209209

210210
const isLoading = useSelector(state => state.queries.isLoading);
211+
const [isRendering, setIsRendering] = useState(false);
211212
// eslint-disable-next-line no-unused-vars
212213
const dispatch = useDispatch();
213214

215+
// Track when data is being processed/rendered
216+
useEffect(() => {
217+
if (isLoading) {
218+
setIsRendering(true);
219+
} else if (finalFilteredResults.length > 0 || queries.length === 0) {
220+
// Small delay to ensure DOM has rendered
221+
const timer = setTimeout(() => {
222+
setIsRendering(false);
223+
}, 100);
224+
return () => clearTimeout(timer);
225+
}
226+
}, [isLoading, finalFilteredResults.length, queries.length]);
227+
214228
// Memoize callbacks to prevent unnecessary re-renders
215229
const updateFilters = useCallback(() => {
216230
// This function might need implementation based on your needs
@@ -413,7 +427,7 @@ const Query = forwardRef(({ fullWidth, queries, searchTerm }, ref) => {
413427
</Box>
414428

415429
<Box overflow='auto' height='calc(100% - 5.375rem)' p={1.5}>
416-
{isLoading ? (
430+
{(isLoading || isRendering) ? (
417431
<Box display="flex" justifyContent="center" alignItems="center" height="40vh">
418432
<CircularProgress />
419433
</Box>

0 commit comments

Comments
 (0)