EnxDev commented on code in PR #45234:
URL: https://github.com/apache/superset/pull/45234#discussion_r4296092944
##########
superset-frontend/plugins/preset-chart-deckgl/src/CategoricalDeckGLContainer.tsx:
##########
@@ -124,16 +160,28 @@ 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) {
Review Comment:
Yes, and it isn't only this container. Fixed in b4c59e90e4.
Every v1 transform builds `payload` as `{...queriesData[0], data}`, and a
chart-data response has no `form_data`, so the `form_data !== stateFormData`
refit never runs once the chart is mounted. Polygon and the
`createDeckGLComponent` factory (Grid, Hex, Heatmap, Contour, Screengrid) have
the same check, so they lost the refit the same way.
All three now call `setViewport(getAdjustedViewport())` when autozoom is on
and the features array changes:
- `CategoricalDeckGLContainer`: in the branch that reconciles categories, as
you suggested
- `Polygon`: same pattern, with a ref to the previous features
- the factory: an effect keyed on the previous payload
`DeckGLContainer` only resets its view state when the `viewport` prop
changes by value. A refresh whose rows fit the same bounds computes an equal
viewport and leaves the viewer's pan alone. A refresh that moves the rows
refits the map, like the remount did. One side effect: with autozoom on, a
resize also refits to the new size, since it produces new features too. Before
this it kept the viewport fitted at the old size.
Tests, each fails without the fix with the map still centered on San
Francisco:
- `CategoricalDeckGLContainer.test.tsx` and the new `factory.test.tsx`: a
response around San Francisco, then a refresh around London. With autozoom the
map ends up on London. Without autozoom it stays on the configured viewport.
- `Polygon.test.tsx`: the same move with polygons and an unchanged
`form_data`.
--
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]