sadpandajoe commented on code in PR #45234:
URL: https://github.com/apache/superset/pull/45234#discussion_r4298263796
##########
superset-frontend/plugins/preset-chart-deckgl/src/CategoricalDeckGLContainer.tsx:
##########
@@ -124,16 +160,32 @@ const CategoricalDeckGLContainer = (props:
CategoricalDeckGLContainerProps) => {
props.payload.form_data,
);
const [viewport, setViewport] = useState(getAdjustedViewport());
+ const featuresRef = useRef(props.payload.data.features);
useEffect(() => {
+ const features = props.payload.data.features || [];
if (props.payload.form_data !== stateFormData) {
- const features = props.payload.data.features || [];
const categories = getCategories(props.formData, features);
setViewport(getAdjustedViewport());
setStateFormData(props.payload.form_data);
setCategories(categories);
+ } else if (props.payload.data.features !== featuresRef.current) {
+ // A dashboard auto-refresh keeps the chart mounted and swaps in new
+ // data without a new form_data, so new categories are merged into the
+ // legend here instead of being filtered out as unknown, and autozoom
+ // refits the map to the new rows.
+ setCategories(previous =>
+ reconcileCategories(
+ previous as Categories,
+ getCategories(props.formData, features),
+ ),
+ );
+ if (props.formData.autozoom) {
Review Comment:
With Auto Zoom on, an Explore pan/zoom/tilt now refits and undoes the
viewer's change. `DeckGLContainer` writes the viewport back through
`setControlValue`, which re-runs the transform with unchanged query results,
and every v1 transform builds a fresh `payload.data.features` array. That trips
this `features !== featuresRef.current` branch, so
`setViewport(getAdjustedViewport())` replaces the user's viewport with the
fitted one on the next throttled update. Before this PR the viewport only reset
when `form_data` changed. Should the refit key on the underlying response (or
compare the rows by value) rather than on the array identity?
--
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]