codeant-ai-for-open-source[bot] commented on code in PR #40656:
URL: https://github.com/apache/superset/pull/40656#discussion_r3337972227
##########
superset-frontend/src/components/TableSelector/index.tsx:
##########
@@ -339,6 +345,11 @@ const TableSelector: FunctionComponent<TableSelectorProps>
= ({
<>
<StyledFormLabel>{label}</StyledFormLabel>
{renderSelectRow(select, refreshLabel)}
+ {data?.hasMore && (
+ <div className="truncated-table-message">
+ {t('Some tables are not shown. Refine your search.')}
+ </div>
+ )}
Review Comment:
**Suggestion:** The truncation helper is rendered whenever the API reports
more results, even in `readOnly` mode where the table input is disabled and
users cannot refine the search. This creates a misleading state ("Refine your
search") with no possible action. Gate this message behind the same
interactivity condition as the table selector (for example, only show it when
the control is actionable). [logic error]
<details>
<summary><b>Severity Level:</b> Minor ๐งน</summary>
```mdx
- โ ๏ธ Read-only datasource editor shows misleading truncation helper text.
- โ ๏ธ Users instructed to refine search on disabled table selector.
```
</details>
<details>
<summary><b>Steps of Reproduction โ
</b></summary>
```mdx
1. In `DatasourceEditor` at
`superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx:1888-1911`,
the `TableSelector` control is rendered with
`readOnly={!this.state.isEditMode}`, so
whenever `this.state.isEditMode` is `false` the `TableSelector` receives
`readOnly={true}`
(see line 1898 and 2111).
2. In `TableSelector` at
`superset-frontend/src/components/TableSelector/index.tsx:310-323`, function
`renderTableSelect` computes `const disabled = readOnly ||
(database?.supports_schemas !==
false && !currentSchema);` and passes this `disabled` flag to the `<Select>`
component, so
when `readOnly` is true the table combobox is disabled and cannot be
interacted with.
3. In the same component, `useTables` is invoked at `index.tsx:191-199`
using the
`useTables` hook from `superset-frontend/src/hooks/apiResources/tables.ts`,
whose
`transformResponse` (lines 115-118) sets `hasMore: json.count >
json.result.length`. The
associated test `useTables` "returns hasMore when total is larger than
result size" in
`tables.test.ts:169-198` shows a concrete case (`fakeHasMoreApiResult`)
where `hasMore`
becomes `true` when the backend truncates table results.
4. Still in `renderTableSelect`, the truncation helper at
`index.tsx:348-352` is rendered
whenever `data?.hasMore` is true: `{data?.hasMore && (<div
className="truncated-table-message">{t('Some tables are not shown. Refine
your
search.')}</div>)}` without checking `readOnly` or `disabled`. Therefore,
when
`DatasourceEditor` passes `readOnly={true}` and the tables API responds with
`hasMore=true`, the UI shows the message "Some tables are not shown. Refine
your search."
under a disabled table selector, instructing the user to refine a search
they cannot
perform.
```
</details>
[Fix in
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c1d46b21fed84d11b2304337ff74bf93&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=c1d46b21fed84d11b2304337ff74bf93&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/src/components/TableSelector/index.tsx
**Line:** 348:352
**Comment:**
*Logic Error: The truncation helper is rendered whenever the API
reports more results, even in `readOnly` mode where the table input is disabled
and users cannot refine the search. This creates a misleading state ("Refine
your search") with no possible action. Gate this message behind the same
interactivity condition as the table selector (for example, only show it when
the control is actionable).
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%2F40656&comment_hash=f9643c41d9f902f75ee51eafdd28605e1afafe99b72b8cf9e5b5a8004ddac60f&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40656&comment_hash=f9643c41d9f902f75ee51eafdd28605e1afafe99b72b8cf9e5b5a8004ddac60f&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]