Skip to content

Commit 98a1615

Browse files
author
Amrit Kashyap Borah
committed
fix: popup menu ref
1 parent 99010be commit 98a1615

2 files changed

Lines changed: 15 additions & 25 deletions

File tree

src/Common/PopupMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ const Button = forwardRef(({
167167
const { handleOpen, popupPosition, buttonRef, initialiseButtonWidth } = usePopupContext()
168168

169169
const refCallback = (node) => {
170-
initialiseButtonWidth.current = node
170+
buttonRef.current = node
171171

172172
if (typeof forwardedRef === 'function') {
173173
forwardedRef(node)

src/Shared/Components/Table/InternalTable.tsx

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,6 @@ const InternalTable = ({
9494
[],
9595
)
9696

97-
const sortByToColumnIndexMap: Record<string, number> = useMemo(
98-
() =>
99-
visibleColumns.reduce((acc, column, index) => {
100-
acc[column.field] = index
101-
102-
return acc
103-
}, {}),
104-
[visibleColumns],
105-
)
106-
10797
const [_areFilteredRowsLoading, filteredRows, filteredRowsError, reloadFilteredRows] = useAsync(async () => {
10898
if (!rows && !getRows) {
10999
throw NO_ROWS_OR_GET_ROWS_ERROR
@@ -112,18 +102,20 @@ const InternalTable = ({
112102
return getFilteringPromise({
113103
searchSortTimeoutRef,
114104
callback: rows
115-
? () => {
116-
const sortByColumnIndex = sortByToColumnIndexMap[sortBy]
117-
118-
return searchAndSortRows(rows, filter, filterData, visibleColumns[sortByColumnIndex]?.comparator)
119-
}
105+
? () =>
106+
searchAndSortRows(
107+
rows,
108+
filter,
109+
filterData,
110+
visibleColumns.find(({ field }) => field === sortBy)?.comparator,
111+
)
120112
: () => getRows(filterData),
121113
})
122-
}, [searchKey, sortBy, sortOrder, rows, sortByToColumnIndexMap, JSON.stringify(otherFilters)])
114+
}, [searchKey, sortBy, sortOrder, rows, JSON.stringify(otherFilters)])
123115

124116
const areFilteredRowsLoading = _areFilteredRowsLoading || filteredRowsError === NO_ROWS_OR_GET_ROWS_ERROR
125117

126-
const bulkSelectionCount = getSelectedIdentifiersCount?.() ?? 0
118+
const bulkSelectionCount = isBulkSelectionApplied && rows ? rows.length : (getSelectedIdentifiersCount?.() ?? 0)
127119

128120
const visibleRows = useMemo(() => {
129121
const normalizedFilteredRows = filteredRows ?? []
@@ -196,13 +188,11 @@ const InternalTable = ({
196188
gridTemplateColumns,
197189
}}
198190
>
199-
{visibleColumns.map(({ horizontallySticky, label }) => (
200-
<div
201-
key={label}
202-
className={`${horizontallySticky ? 'dc__position-sticky dc__left-0 dc__zi-1' : ''} pr-12 py-12 flex`}
203-
aria-label="Loading..."
204-
>
205-
<div className="shimmer h-16 w-100" />
191+
{visibleColumns.map(({ label, field }) => (
192+
<div key={label} className="pr-6 py-12 flex" aria-label="Loading...">
193+
<div
194+
className={`shimmer h-16 ${field === BULK_ACTION_GUTTER_LABEL ? 'w-20 mr-6' : 'w-100'}`}
195+
/>
206196
</div>
207197
))}
208198
</div>

0 commit comments

Comments
 (0)