Skip to content

Commit 19a676e

Browse files
committed
Update logic for displying org search results (#1039)
1 parent ac0ec95 commit 19a676e

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

src/pages/Contributors/AffiliatedOrganizations.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,16 @@ export const AffiliatedOrganizations = ({
123123
return parentdata;
124124
};
125125

126-
const [currentThumbnails, setCurrentThumbnails] = useState(getParentData);
126+
const [currentThumbnails, setCurrentThumbnails] = useState([]);
127127

128128
useEffect(() => {
129-
setCurrentThumbnails(getParentData);
130-
// eslint-disable-next-line react-hooks/exhaustive-deps
131-
}, [
132-
inputValue,
133-
organizations,
134-
organizationData,
135-
showIndexContrib,
136-
filtersActive,
137-
]);
129+
setCurrentThumbnails(getParentData());
130+
// eslint-disable-next-line react-hooks/exhaustive-deps
131+
}, [organizations]);
138132

139133
let childSort;
140134
let childNode;
141-
if (currentThumbnails && inputValue.length === 0) {
135+
if (!filtersActive) {
142136
return (
143137
<Grid
144138
className={classes.thumbnailGrid}
@@ -147,7 +141,7 @@ export const AffiliatedOrganizations = ({
147141
>
148142
{currentThumbnails.map((org, i) => {
149143
childSort = org.childNodes;
150-
childNode = org.isOpen ? childSort : childSort.slice(0, 8);
144+
childNode = org.isOpen ? childSort : childSort.slice(0, 6);
151145
return (
152146
<Dropdown
153147
checkboxValue={showIndexContrib}
@@ -200,7 +194,7 @@ export const AffiliatedOrganizations = ({
200194
filtersActive={filtersActive}
201195
/>
202196
)}
203-
{org.childNodes.length > 8 ? (
197+
{org.childNodes.length > 6 ? (
204198
<Grid
205199
item
206200
container
@@ -227,12 +221,7 @@ export const AffiliatedOrganizations = ({
227221
})}
228222
</Grid>
229223
);
230-
} else if (
231-
currentThumbnails &&
232-
inputValue !== null &&
233-
inputValue.length > 0 &&
234-
inputValue !== ''
235-
) {
224+
} else {
236225
return (
237226
<Grid
238227
className={classes.thumbnailGrid}
@@ -244,7 +233,7 @@ export const AffiliatedOrganizations = ({
244233
organization={org}
245234
key={`affiliatedThumbnailsWrapper_${i}`}
246235
dropdownLength={org.childNodes.length}
247-
isOpen={org.childNodes.length <= 5 ? true : false}
236+
isOpen={org.childNodes.length <= 6 && i === 0}
248237
inputValue={inputValue}
249238
checkboxValue={showIndexContrib}
250239
filtersActive={filtersActive}

0 commit comments

Comments
 (0)