codeant-ai-for-open-source[bot] commented on code in PR #40697:
URL: https://github.com/apache/superset/pull/40697#discussion_r3345882477


##########
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/filterTransformer.ts:
##########
@@ -131,6 +131,7 @@ function transformFormInput(
     requiredFirst: formInputs.requiredFirst
       ? Object.values(formInputs.requiredFirst).find(rf => rf)
       : undefined,
+    titleLabel: formInputs.titleLabel || undefined,

Review Comment:
   **Suggestion:** `titleLabel` is saved without trimming, so a value 
containing only whitespace is treated as a valid custom label and later 
rendered as an empty-looking filter name in dynamic titles. Normalize it by 
trimming first, then store `undefined` when the trimmed value is empty. [logic 
error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Dynamic chart titles show blank-looking filter labels.
   - ⚠️ Users may misread which filters are applied.
   - ⚠️ Affects charts with show_dynamic_title enabled.
   - ⚠️ Impacts native filter configuration and saved dashboards.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open the native filters configuration modal where the "Chart title label" 
input is
   rendered at
   
`superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx:15-32`
   (the `StyledFormItem` with `name={['filters', filterId, 'titleLabel']}` and 
`<Input>`).
   
   2. Save the modal so that `useModalSaveLogic` runs in
   
`superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/hooks/useModalSaveLogic.ts:18-31`,
   which calls `transformFilterForSave(id, mergedValues.filters?.[id] ||
   updatedFilterConfigMap[id])` for each modified filter.
   
   3. In `transformFilterForSave` → `transformFilter` → `transformFormInput` at
   
`superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/filterTransformer.ts:17-36`,
   the filter object is built with `description: (formInputs.description || 
'').trim()` but
   `titleLabel: formInputs.titleLabel || undefined` (no trim). If the user 
entered `" "`
   (spaces) in the UI, the persisted filter has `titleLabel` set to `" "` 
instead of
   `undefined`.
   
   4. When a chart with dynamic titles enabled is rendered, 
`getDisplaySliceTitle` in
   
`superset-frontend/src/explore/components/ExploreViewContainer/index.tsx:25-114`
 executes.
   It collects active filters from `adhoc_filters` and 
`extra_form_data.filters` into
   `activeFilters` (lines 47-56) and uses `getFilterName` (lines 58-94), which 
checks `if
   (typeof filterMeta.titleLabel === 'string' && filterMeta.titleLabel.length > 
0)` (lines
   63-67). The whitespace-only `titleLabel` has length > 0, so `getFilterName` 
returns `" "`.
   This produces `activeFilterNames` entries that visually render as blank, and 
the final
   title suffix `by ${activeFilterNames.join(', ')}` (lines 96-112) appears with
   empty-looking filter names instead of falling back to subject/column/label.
   ```
   </details>
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=400a2bc6387d4919ad1bc8abf44880e6&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=400a2bc6387d4919ad1bc8abf44880e6&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/dashboard/components/nativeFilters/FiltersConfigModal/transformers/filterTransformer.ts
   **Line:** 134:134
   **Comment:**
        *Logic Error: `titleLabel` is saved without trimming, so a value 
containing only whitespace is treated as a valid custom label and later 
rendered as an empty-looking filter name in dynamic titles. Normalize it by 
trimming first, then store `undefined` when the trimmed value is empty.
   
   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%2F40697&comment_hash=5164aae9038838ff3534be21a8e9057f9dd34a41f7b688ba16e17a8d8b76fd58&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40697&comment_hash=5164aae9038838ff3534be21a8e9057f9dd34a41f7b688ba16e17a8d8b76fd58&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]

Reply via email to