Skip to content

Commit 9954a2a

Browse files
committed
Fix loading target selector
1 parent e616001 commit 9954a2a

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

components/dash-core-components/src/components/Loading.react.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {useState, useRef, useMemo, useEffect} from 'react';
2-
import {equals, concat, includes, toPairs} from 'ramda';
2+
import {equals, concat, includes, toPairs, any} from 'ramda';
33
import PropTypes from 'prop-types';
44

55
import GraphSpinner from '../fragments/Loading/spinners/GraphSpinner.jsx';
@@ -35,19 +35,21 @@ const loadingSelector = (componentPath, targetComponents) => state => {
3535
stringPath = stringPath.substring(0, stringPath.length - 1);
3636
const loadingChildren = toPairs(state.loading).reduce(
3737
(acc, [path, load]) => {
38-
if (path.startsWith(stringPath)) {
39-
if (targetComponents) {
40-
const target = targetComponents[load.id];
41-
if (!target) {
42-
return acc;
43-
}
44-
if (Array.isArray(target)) {
45-
if (!includes(load.property, target)) {
46-
return acc;
38+
if (path.startsWith(stringPath) && load.length) {
39+
if (
40+
targetComponents &&
41+
!any(l => {
42+
const target = targetComponents[l.id];
43+
if (!target) {
44+
return false;
4745
}
48-
} else if (load.property !== target) {
49-
return acc;
50-
}
46+
if (Array.isArray(target)) {
47+
return includes(l.property, target);
48+
}
49+
return l.property === target;
50+
}, load)
51+
) {
52+
return acc;
5153
}
5254
return concat(acc, load);
5355
}

0 commit comments

Comments
 (0)