sadpandajoe opened a new issue, #44917:
URL: https://github.com/apache/superset/issues/44917
### Bug description
`ComparisonRangeLabel` returns `null` only when `labels.length === 0`. In
the custom/inherit branches the fetch chain resolves `{ value: '' }` when no
range can be computed (e.g. a custom start date later than the current range
start, or "custom" selected with no start date). `setLabels(res.map(r =>
r.value ?? ''))` then produces `['']`, which has length 1, so the control
renders the "Actual range for comparison" header followed by an empty line.
Steps to reproduce: Time comparison with a "Custom" shift and a start date
that is after the chart's time range start (or Custom with no start date). The
header renders with nothing under it.
Expected: render nothing (or a fallback such as "unavailable") when there is
no non-empty label.
Minor, same component: the `labels.flat().map` renders a keyed `<div>`
inside an unkeyed Fragment (React key warning; duplicate labels would also
collide).
### Where
`superset-frontend/src/explore/components/controls/ComparisonRangeLabel.tsx`
- L169, L172 `Promise.resolve({ value: '' })`
- L176 `setLabels(res.map(r => r.value ?? ''));`
- L181-L198 `labels.length ? (<ControlHeader .../> ...) : null`
### Suggested fix
Filter out empty strings before `setLabels` (or test `labels.some(Boolean)`
in the render), and drop the redundant Fragment / key the Fragment.
### Found by
Found while adding React Testing Library coverage for Explore controls (all
line numbers are against `master` at `bc3698b5d6`).
--
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]