Skip to content

Commit 725d754

Browse files
author
Amrit Borah
committed
fix: loading state logic
1 parent 71de0d5 commit 725d754

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

src/Shared/Components/Table/TableContent.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,9 @@ const TableContent = <
175175

176176
const bulkSelectionCount = isBulkSelectionApplied ? totalRows : (getSelectedIdentifiersCount?.() ?? 0)
177177

178-
const isBEPagination = !!getRows
179-
180178
const showPagination =
181179
paginationVariant === PaginationEnum.PAGINATED &&
182-
((isBEPagination && totalRows) || filteredRows?.length) >
183-
(pageSizeOptions?.[0]?.value ?? DEFAULT_BASE_PAGE_SIZE)
180+
totalRows > (pageSizeOptions?.[0]?.value ?? DEFAULT_BASE_PAGE_SIZE)
184181

185182
const { activeRowIndex, setActiveRowIndex, shortcutContainerProps } = useTableWithKeyboardShortcuts(
186183
{ bulkSelectionConfig, bulkSelectionReturnValue, handleToggleBulkSelectionOnRow },
@@ -202,6 +199,11 @@ const TableContent = <
202199
)
203200
}, [visibleRows])
204201

202+
const numberOfColumnsWithoutBulkActionGutter = useMemo(
203+
() => visibleColumns.filter(({ field }) => field !== BULK_ACTION_GUTTER_LABEL),
204+
[visibleColumns],
205+
)
206+
205207
const getTriggerSortingHandler = (newSortBy: string) => () => {
206208
handleSorting(newSortBy)
207209
}
@@ -298,24 +300,26 @@ const TableContent = <
298300
return Object.values(bulkSelectionState)
299301
}
300302

301-
const showIconOrExpandActionGutter = isBulkSelectionConfigured || !!rowStartIconConfig || isAnyRowExpandable
303+
const showIconOrExpandActionGutter = !!rowStartIconConfig || isAnyRowExpandable
302304

303305
const renderRows = () => {
304-
if (loading && !visibleColumns.length) {
306+
if (loading && !numberOfColumnsWithoutBulkActionGutter.length) {
305307
return SHIMMER_DUMMY_ARRAY.map((shimmerRowLabel) => (
306308
<div
307309
key={shimmerRowLabel}
308310
className={`px-20 flex left py-12 dc__gap-16 ${showSeparatorBetweenRows ? 'border__secondary--bottom' : ''}`}
309311
>
310-
{showIconOrExpandActionGutter ? <div className="shimmer w-20" /> : null}
312+
{showIconOrExpandActionGutter || isBulkSelectionConfigured ? (
313+
<div className="shimmer w-20" />
314+
) : null}
311315
{SHIMMER_DUMMY_ARRAY.map((shimmerCellLabel) => (
312316
<div key={shimmerCellLabel} className="shimmer w-200" />
313317
))}
314318
</div>
315319
))
316320
}
317321

318-
if (areFilteredRowsLoading || (loading && visibleColumns.length)) {
322+
if ((loading && numberOfColumnsWithoutBulkActionGutter.length) || areFilteredRowsLoading) {
319323
return SHIMMER_DUMMY_ARRAY.map((shimmerRowLabel) => (
320324
<div
321325
key={shimmerRowLabel}
@@ -525,9 +529,11 @@ const TableContent = <
525529
ref={headerRef}
526530
className="bg__primary dc__min-width-fit-content px-20 border__secondary--bottom dc__position-sticky dc__zi-2 dc__top-0 generic-table__header"
527531
>
528-
{loading && !visibleColumns.length ? (
532+
{loading && !numberOfColumnsWithoutBulkActionGutter.length ? (
529533
<div className="flexbox py-12 dc__gap-16">
530-
{showIconOrExpandActionGutter ? <div className="shimmer w-20" /> : null}
534+
{showIconOrExpandActionGutter || isBulkSelectionConfigured ? (
535+
<div className="shimmer w-20" />
536+
) : null}
531537
{SHIMMER_DUMMY_ARRAY.map((label) => (
532538
<div key={label} className="shimmer w-200" />
533539
))}

0 commit comments

Comments
 (0)