fitzee opened a new pull request, #39885:
URL: https://github.com/apache/superset/pull/39885

   ### SUMMARY
   
   The Table V2 chart's `TextCellRenderer` renders cells containing HTML markup 
(e.g. anchor tags) via `dangerouslySetInnerHTML`, but the column definition's 
`filterValueGetter` and `comparator` are not configured for string columns. 
Both filter and sort therefore operate on the raw HTML string instead of the 
visible text:
   
   - **Sort:** Rows are ordered by raw HTML lexically. The URL inside the 
markup dictates ordering instead of the visible label — e.g. all rows whose 
anchor `href` starts with `https://aaa/...` sort before rows with 
`https://bbb/...` regardless of what label is shown to the user.
   - **"Contains" filter:** Matches against the raw HTML string. Typing a 
fragment of the visible label may miss; typing a URL substring (e.g. `https`) 
matches every HTML row.
   
   This change adds a small `htmlTextFilterValueGetter` utility (with a 
matching `htmlTextComparator`) that extracts the visible text from HTML values 
via `DOMParser` + `sanitizeHtml`, and wires it into the colDef for string 
columns. Pass-through for non-HTML values, so plain string columns are 
unaffected.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Not applicable — the bug is observable via sort order rather than a visually 
distinct rendering.
   
   ### TESTING INSTRUCTIONS
   
   1. Enable the `AG_GRID_TABLE_ENABLED` feature flag.
   2. Create a Table V2 chart against a dataset where one string column 
contains HTML, e.g. via a calculated column: `'<a href="https://example.com/' 
|| id || '">label_' || id || '</a>'`
   3. **Before this fix:** clicking the column header sorts by URL prefix, not 
the visible label. Typing the label text into the column's "Contains" filter 
may not match.
   4. **After this fix:** sort matches the visible label order; the "Contains" 
filter matches the visible label.
   
   Unit tests added in `htmlTextFilterValueGetter.test.ts` cover HTML 
extraction (anchor and nested markup), pass-through for plain strings, nulls, 
and numbers, plus the comparator's ordering and null handling.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [x] Required feature flags: `AG_GRID_TABLE_ENABLED`
   - [x] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
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