Skip to content

Commit 8f5fdcd

Browse files
Merge pull request KelvinTegelaar#4868 from kris6673/fix-skeleton-missing
Fix: Fix skeleton loading display when propertyItems array is empty
2 parents 8104cd0 + 159531a commit 8f5fdcd

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

src/components/CippCards/CippPropertyListCard.jsx

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ export const CippPropertyListCard = (props) => {
6262
<PropertyList>
6363
{isFetching ? (
6464
<>
65-
{propertyItems.map((item, index) => (
65+
{Array.from({ length: propertyItems?.length || 3 }).map((_, index) => (
6666
<PropertyListItem
67-
key={`${index}-index-PropertyListOffCanvas`}
67+
key={`${index}-skeleton-PropertyListOffCanvas`}
6868
align={align}
69-
label={item.label}
69+
label={propertyItems?.[index]?.label || ""}
7070
value={<Skeleton width={280} />}
7171
sx={setPadding}
7272
/>
@@ -87,7 +87,7 @@ export const CippPropertyListCard = (props) => {
8787
</PropertyList>
8888
) : (
8989
// Two-column layout
90-
(<Stack
90+
<Stack
9191
direction={{
9292
xs: "column",
9393
md: "row",
@@ -102,13 +102,17 @@ export const CippPropertyListCard = (props) => {
102102
>
103103
<PropertyList>
104104
{isFetching ? (
105-
<PropertyListItem
106-
key={"loading-bar"}
107-
align={align}
108-
divider={showDivider}
109-
label="Loading"
110-
value={<Skeleton width={280} />}
111-
/>
105+
<>
106+
{Array.from({ length: Math.max(1, firstHalf?.length || 1) }).map((_, index) => (
107+
<PropertyListItem
108+
key={`${index}-skeleton-first`}
109+
align={align}
110+
divider={showDivider}
111+
label=""
112+
value={<Skeleton width={280} />}
113+
/>
114+
))}
115+
</>
112116
) : (
113117
firstHalf.map((item, index) => (
114118
<PropertyListItem
@@ -123,13 +127,19 @@ export const CippPropertyListCard = (props) => {
123127
</PropertyList>
124128
<PropertyList>
125129
{isFetching ? (
126-
<PropertyListItem
127-
key={"loading-bar"}
128-
align={align}
129-
divider={showDivider}
130-
label="Loading"
131-
value={<Skeleton width={280} />}
132-
/>
130+
<>
131+
{Array.from({ length: Math.max(1, secondHalf?.length || 1) }).map(
132+
(_, index) => (
133+
<PropertyListItem
134+
key={`${index}-skeleton-second`}
135+
align={align}
136+
divider={showDivider}
137+
label=""
138+
value={<Skeleton width={280} />}
139+
/>
140+
)
141+
)}
142+
</>
133143
) : (
134144
secondHalf.map((item, index) => (
135145
<PropertyListItem
@@ -142,7 +152,7 @@ export const CippPropertyListCard = (props) => {
142152
))
143153
)}
144154
</PropertyList>
145-
</Stack>)
155+
</Stack>
146156
)}
147157
</CardContent>
148158
<ActionList>

0 commit comments

Comments
 (0)