codeant-ai-for-open-source[bot] commented on code in PR #36073:
URL: https://github.com/apache/superset/pull/36073#discussion_r3505079078
##########
superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx:
##########
@@ -576,30 +580,32 @@ export default typedMemo(function DataTable<D extends
object>({
/>
) : null}
<Flex wrap align="center" gap="middle">
- {serverPagination && searchInput && (
- <Space size="small" className="search-select-container">
- <span className="search-by-label">{t('Search by')}:</span>
- <SearchSelectDropdown
- searchOptions={searchOptions}
- value={serverPaginationData?.searchColumn || ''}
- onChange={onSearchColChange}
- />
- </Space>
- )}
{searchInput && (
- <GlobalFilter<D>
- searchInput={
- typeof searchInput === 'boolean' ? undefined : searchInput
- }
- preGlobalFilteredRows={preGlobalFilteredRows}
- setGlobalFilter={
- manualSearch ? handleSearchChange : setGlobalFilter
- }
- filterValue={manualSearch ? initialSearchText : filterValue}
- id={searchInputId}
- serverPagination={!!serverPagination}
- rowCount={rowCount}
- />
+ <>
+ {serverPagination && (
+ <Space direction="vertical" size={4}>
+ {t('Search by')}
+ <SearchSelectDropdown
+ searchOptions={searchOptions}
+ value={serverPaginationData?.searchColumn || ''}
Review Comment:
**Suggestion:** Using an empty-string fallback here forces the dropdown into
a controlled `''` value when no `searchColumn` exists, which prevents the
dropdown’s own default-first-option logic from applying and leaves “Search by”
visually unselected while search requests still default to the first option.
Pass the raw nullable value instead so the select can correctly initialize to a
real option. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Table chart "Search by" dropdown shows no selected column.
- ⚠️ Server search uses first column while dropdown appears empty.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Inspect `DataTableProps` in
`superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx:72-77`,
where
`serverPaginationData.searchColumn` is defined as an optional field
(`searchColumn?:
string;`), meaning it can be absent on initial render.
2. Observe the search handler in
`superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx:1539-1545`,
where
`handleSearch` builds `modifiedOwnState` with `searchColumn:
serverPaginationData?.searchColumn || searchOptions[0]?.value`, explicitly
defaulting the
server-side search column to the first entry in `searchOptions` when
`searchColumn` is
undefined.
3. Check the `SearchSelectDropdown` implementation in
`superset-frontend/plugins/plugin-chart-table/src/DataTable/components/SearchSelectDropdown.tsx:14-26`,
where the underlying AntD Select receives `value={value ??
searchOptions?.[0]?.value}`;
this means it only falls back to the first option when its `value` prop is
`null` or
`undefined`, not when it is an empty string.
4. Examine the DataTable controls in
`superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx:586-592`,
where
the dropdown is rendered as:
- `<SearchSelectDropdown ... value={serverPaginationData?.searchColumn ||
''} ... />`
at line 590. For any Table chart with server pagination + search enabled
where
`serverPaginationData.searchColumn` is currently undefined (as allowed by
the type and
expected by `handleSearch`), this expression evaluates to `''` and passes
that to
`SearchSelectDropdown`. Because `SearchSelectDropdown` treats `''` as a
defined value,
the internal `value ?? searchOptions[0]?.value` fallback is bypassed, so
the “Search
by” dropdown appears visually unselected while `handleSearch` still
defaults the actual
search column to `searchOptions[0]?.value`. Thus, the UI and server
search behavior
diverge, reproducing the bug described in the suggestion.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=78c9076870914dc39d50348121de29bb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=78c9076870914dc39d50348121de29bb&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/plugins/plugin-chart-table/src/DataTable/DataTable.tsx
**Line:** 590:590
**Comment:**
*Logic Error: Using an empty-string fallback here forces the dropdown
into a controlled `''` value when no `searchColumn` exists, which prevents the
dropdown’s own default-first-option logic from applying and leaves “Search by”
visually unselected while search requests still default to the first option.
Pass the raw nullable value instead so the select can correctly initialize to a
real option.
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%2F36073&comment_hash=12e0a0ff5937dcfea59bf2207ef95c7ef4ec35602bee5ebece34d51e16a44659&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F36073&comment_hash=12e0a0ff5937dcfea59bf2207ef95c7ef4ec35602bee5ebece34d51e16a44659&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]