Skip to content

fix(AnalyticalTable): fix React key warning #7100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { classNames, styleData } from './Resizer.module.css.js';
import { ColumnHeader } from './index.js';

interface ColumnHeaderContainerProps {
headerProps: Record<string, unknown>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
headerProps: Record<string, any>;
headerGroup: Record<string, any>;
onSort: (e: CustomEvent<{ column: unknown; sortDirection: string }>) => void;
onGroupByChanged: (e: CustomEvent<{ column?: Record<string, unknown>; isGrouped?: boolean }>) => void;
Expand All @@ -32,12 +31,14 @@ export const ColumnHeaderContainer = forwardRef<HTMLDivElement, ColumnHeaderCont
uniqueId,
showVerticalEndBorder
} = props;
const { key, ...reactTableHeaderProps } = headerProps;

useStylesheet(styleData, 'Resizer');

return (
<div
{...headerProps}
key={key}
{...reactTableHeaderProps}
style={{ width: `${columnVirtualizer.getTotalSize()}px` }}
ref={ref}
data-component-name="AnalyticalTableHeaderRow"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const VirtualTableBody = (props: VirtualTableBodyProps) => {
lastNonEmptyRow.current = row;
}
prepareRow(row);
const rowProps = row.getRowProps({
const { key, ...rowProps } = row.getRowProps({
'aria-rowindex': virtualRow.index + 1,
'data-virtual-row-index': virtualRow.index
});
Expand Down Expand Up @@ -190,8 +190,8 @@ export const VirtualTableBody = (props: VirtualTableBodyProps) => {
: rowVirtualizer.measureElement;

return (
// eslint-disable-next-line react/jsx-key
<div
key={key}
{...rowProps}
ref={measureRef}
style={{
Expand Down Expand Up @@ -227,7 +227,7 @@ export const VirtualTableBody = (props: VirtualTableBodyProps) => {
if (!cell) {
return null;
}
const cellProps = cell.getCellProps();
const { key, ...cellProps } = cell.getCellProps();
const allCellProps = {
...cellProps,
['data-visible-column-index']: visibleColumnIndex,
Expand Down Expand Up @@ -269,8 +269,11 @@ export const VirtualTableBody = (props: VirtualTableBodyProps) => {
}

return (
// eslint-disable-next-line react/jsx-key
<div {...allCellProps} data-selection-cell={cell.column.id === '__ui5wcr__internal_selection_column'}>
<div
key={key}
{...allCellProps}
data-selection-cell={cell.column.id === '__ui5wcr__internal_selection_column'}
>
{popInRowHeight !== internalRowHeight && popInColumn.id === cell.column.id
? cell.render('PopIn', { contentToRender, internalRowHeight })
: cell.render(contentToRender, isNavigatedCell === true ? { isNavigatedCell } : {})}
Expand Down
Loading