You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ms...@apache.org on 2025/12/23 10:40:53 UTC
(superset) branch msyavuz/fix/highlight-class-undefined created (now 7ec61a0b5a)
This is an automated email from the ASF dual-hosted git repository.
msyavuz pushed a change to branch msyavuz/fix/highlight-class-undefined
in repository https://gitbox.apache.org/repos/asf/superset.git
at 7ec61a0b5a test: add tests for the fix
This branch includes the following new commits:
new 9e569e8f12 fix: only apply highlight class if it's defined
new 7ec61a0b5a test: add tests for the fix
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/02: fix: only apply highlight class if it's defined
Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
msyavuz pushed a commit to branch msyavuz/fix/highlight-class-undefined
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 9e569e8f12ff678915341651a8d74772d9f011cf
Author: Mehmet Salih Yavuz <sa...@proton.me>
AuthorDate: Tue Dec 23 13:38:52 2025 +0300
fix: only apply highlight class if it's defined
---
.../superset-ui-core/src/components/TableCollection/index.tsx | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/packages/superset-ui-core/src/components/TableCollection/index.tsx b/superset-frontend/packages/superset-ui-core/src/components/TableCollection/index.tsx
index 732ef675c4..1edd0f440f 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/TableCollection/index.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/TableCollection/index.tsx
@@ -280,7 +280,9 @@ function TableCollection<T extends object>({
const getRowClassName = useCallback(
(record: Record<string, unknown>) =>
- record?.id === highlightRowId ? 'table-row-highlighted' : '',
+ highlightRowId !== undefined && record?.id === highlightRowId
+ ? 'table-row-highlighted'
+ : '',
[highlightRowId],
);
(superset) 02/02: test: add tests for the fix
Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
msyavuz pushed a commit to branch msyavuz/fix/highlight-class-undefined
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 7ec61a0b5a4e01c25a81d537e5bd311d8042fdd8
Author: Mehmet Salih Yavuz <sa...@proton.me>
AuthorDate: Tue Dec 23 13:40:28 2025 +0300
test: add tests for the fix
---
.../TableCollection/TableCollection.test.tsx | 81 ++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx
index 39620b9ecd..4136a9d770 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/TableCollection/TableCollection.test.tsx
@@ -240,3 +240,84 @@ test('should call setSortBy when clicking sortable column header', () => {
},
]);
});
+
+test('should not apply highlight class when highlightRowId is undefined', () => {
+ const propsWithoutHighlight = {
+ ...defaultProps,
+ highlightRowId: undefined,
+ };
+
+ const { container } = render(<TableCollection {...propsWithoutHighlight} />);
+
+ // Check that no rows have the highlight class
+ const highlightedRows = container.querySelectorAll('.table-row-highlighted');
+ expect(highlightedRows).toHaveLength(0);
+});
+
+test('should not apply highlight class when highlightRowId is null', () => {
+ const propsWithNullHighlight = {
+ ...defaultProps,
+ highlightRowId: null,
+ };
+
+ const { container } = render(<TableCollection {...propsWithNullHighlight} />);
+
+ // Check that no rows have the highlight class
+ const highlightedRows = container.querySelectorAll('.table-row-highlighted');
+ expect(highlightedRows).toHaveLength(0);
+});
+
+test('should apply highlight class only to matching row when highlightRowId is provided', () => {
+ // Create data where the first row has id: 1 to match highlightRowId: 1
+ const dataWithIds = [
+ {
+ col1: 'Line 01 - Col 01',
+ col2: 'Line 01 - Col 02',
+ id: 1, // This should be highlighted
+ parent: { child: 'Nested Value 1' },
+ },
+ {
+ col1: 'Line 02 - Col 01',
+ col2: 'Line 02 - Col 02',
+ id: 2,
+ parent: { child: 'Nested Value 2' },
+ },
+ {
+ col1: 'Line 03 - Col 01',
+ col2: 'Line 03 - Col 02',
+ id: 3,
+ parent: { child: 'Nested Value 3' },
+ },
+ ];
+
+ // Create new table hook with data that has ids
+ const { result } = renderHook(() => useTable({ columns: tableHook.columns, data: dataWithIds }));
+ const newTableHook = result.current;
+
+ const propsWithHighlight = {
+ ...defaultProps,
+ highlightRowId: 1,
+ rows: newTableHook.rows,
+ prepareRow: newTableHook.prepareRow,
+ };
+
+ const { container } = render(<TableCollection {...propsWithHighlight} />);
+
+ // Check that only one row has the highlight class
+ const highlightedRows = container.querySelectorAll('.table-row-highlighted');
+ expect(highlightedRows).toHaveLength(1);
+});
+
+test('should not apply highlight when records have no id field and highlightRowId is undefined', () => {
+ // This is the key test for the bug fix - use original data without id field
+ const propsWithNoIds = {
+ ...defaultProps,
+ highlightRowId: undefined,
+ };
+
+ const { container } = render(<TableCollection {...propsWithNoIds} />);
+
+ // Check that no rows have the highlight class (was the bug: all rows were highlighted)
+ const highlightedRows = container.querySelectorAll('.table-row-highlighted');
+ expect(highlightedRows).toHaveLength(0);
+});