codeant-ai-for-open-source[bot] commented on code in PR #39980:
URL: https://github.com/apache/superset/pull/39980#discussion_r3358094112
##########
superset-frontend/packages/superset-ui-core/src/components/TableCollection/index.tsx:
##########
@@ -306,9 +317,18 @@ function TableCollection<T extends object>({
rowClassName={getRowClassName}
components={{
header: {
- cell: (props: HTMLAttributes<HTMLTableCellElement>) => (
- <th {...props} data-test="sort-header" />
- ),
+ cell: (props: HTMLAttributes<HTMLTableCellElement>) => {
+ const isSelectionColumn =
+ props.className?.includes('ant-table-selection-column') ?? false;
+ return (
+ <th
+ {...props}
+ data-test={
+ isSelectionColumn ? 'header-toggle-all' : 'sort-header'
+ }
Review Comment:
**Suggestion:** The new header-cell override assigns
`data-test="sort-header"` to every non-selection header cell, including columns
that are explicitly non-sortable (for example action columns with
`disableSortBy`). This makes test/automation selectors semantically incorrect
and can cause click-on-sort-header flows to target a header that cannot sort.
Only mark headers as `sort-header` when the underlying column is actually
sortable, and use a different marker (or none) for non-sortable headers. [logic
error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ ListView-based pages mislabel non-sortable headers as sortable.
- ⚠️ RolesList Actions column gets `data-test="sort-header"` despite
`disableSortBy`.
- ⚠️ Automation using `sort-header` may click unsortable headers.
- ⚠️ Future sort tests can silently exercise non-sortable columns.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. In `RolesList` the table columns include an explicit non-sortable action
column:
`superset-frontend/src/pages/RolesList/index.tsx:16-21` (lines 16–21 in the
snippet at
210–249) defines a column with `Header: t('Actions')`, `id: 'actions'`, and
`disableSortBy: true`.
2. The `RolesList` page renders these `columns` through the shared
`ListView` component:
`superset-frontend/src/pages/RolesList/index.tsx:11-22` (snippet at 372–395)
passes
`columns={columns}` into `<ListView<RoleObject> ... />`, and `ListView` in
turn renders
`<TableCollection ... columns={columns} />` when `viewMode === 'table'` at
`superset-frontend/src/components/ListView/ListView.tsx:585-593`.
3. Inside `TableCollection`, `columns` are converted into Ant Design column
definitions
via `mapColumns` in
`superset-frontend/packages/superset-ui-core/src/components/TableCollection/utils.tsx:5-16`,
which sets `sorter: !column.disableSortBy`; for the `Actions` column
(`disableSortBy:
true`) this yields `sorter: false`, so the column is intentionally
non-sortable.
4. The same `TableCollection` overrides the table header cell renderer at
`superset-frontend/packages/superset-ui-core/src/components/TableCollection/index.tsx:320-329`,
where every non-selection `<th>` (including the non-sortable `Actions`
column) is rendered
with `data-test={isSelectionColumn ? 'header-toggle-all' : 'sort-header'}`
(lines
321–328). As a result, headers for columns like `Actions` that cannot
actually sort still
carry `data-test="sort-header"`, so any automation or tests that treat
`sort-header` as
"sortable header" can target a header that does not trigger sorting (e.g.,
using
`screen.getAllByTestId('sort-header')` as in `ListView.test.tsx:22-27`),
leading to
semantically incorrect selectors and potential false assumptions about sort
behavior.
```
</details>
[Fix in
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=dafceef7ed1c43a997c52abaee0657db&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
| [Fix in VSCode
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=dafceef7ed1c43a997c52abaee0657db&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/packages/superset-ui-core/src/components/TableCollection/index.tsx
**Line:** 326:328
**Comment:**
*Logic Error: The new header-cell override assigns
`data-test="sort-header"` to every non-selection header cell, including columns
that are explicitly non-sortable (for example action columns with
`disableSortBy`). This makes test/automation selectors semantically incorrect
and can cause click-on-sort-header flows to target a header that cannot sort.
Only mark headers as `sort-header` when the underlying column is actually
sortable, and use a different marker (or none) for non-sortable headers.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39980&comment_hash=736b5bdc9ce7b773db2f0e73cba39853a463fe09937424e4127caca4ea61ba63&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39980&comment_hash=736b5bdc9ce7b773db2f0e73cba39853a463fe09937424e4127caca4ea61ba63&reaction=dislike'>👎</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]