Skip to content

Commit db1a5b6

Browse files
authored
EZP-31968: Added spinner to UDW (#1642)
1 parent 0eceb7f commit db1a5b6

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

src/bundle/Resources/public/scss/ui/modules/universal-discovery/_finder.branch.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,11 @@
6262
top: 0;
6363
right: 0;
6464
}
65+
66+
&__loading-spinner {
67+
display: flex;
68+
align-items: center;
69+
justify-content: center;
70+
margin-top: calculateRem(50px);
71+
}
6572
}

src/bundle/ui-dev/src/modules/universal-discovery/components/finder/finder.branch.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ const FinderBranch = ({ locationData, itemsPerPage }) => {
111111
return (
112112
<Fragment>
113113
<div className="c-finder-branch__items-wrapper" onScroll={loadMore} style={{ width }}>
114+
{renderLoadingSpinner()}
115+
114116
{subitems.map(({ location }) => (
115117
<FinderLeaf key={location.id} location={location} />
116118
))}
@@ -119,18 +121,27 @@ const FinderBranch = ({ locationData, itemsPerPage }) => {
119121
</Fragment>
120122
);
121123
};
122-
123-
useEffect(() => {
124-
if (isLoading || !loadedLocations.subitems) {
124+
const renderLoadingSpinner = () => {
125+
if (!isLoading) {
125126
return;
126127
}
127128

128-
const data = { ...locationData, ...loadedLocations, subitems: [...locationData.subitems, ...loadedLocations.subitems] };
129+
return (
130+
<div className="c-finder-branch__loading-spinner">
131+
<Icon name="spinner" extraClasses="ez-icon--medium ez-spin" />
132+
</div>
133+
);
134+
}
135+
136+
useEffect(() => {
137+
if (loadedLocations.subitems) {
138+
const data = { ...locationData, ...loadedLocations, subitems: [...locationData.subitems, ...loadedLocations.subitems] };
129139

130-
dispatchLoadedLocationsAction({ type: 'UPDATE_LOCATIONS', data });
140+
dispatchLoadedLocationsAction({ type: 'UPDATE_LOCATIONS', data });
141+
}
131142
}, [loadedLocations, dispatchLoadedLocationsAction, isLoading]);
132143

133-
if (!subitems.length && !collapsed) {
144+
if (!subitems.length && !collapsed && !isLoading) {
134145
return null;
135146
}
136147

0 commit comments

Comments
 (0)