EnxDev commented on code in PR #45541:
URL: https://github.com/apache/superset/pull/45541#discussion_r4382467348
##########
superset-frontend/src/components/Chart/ChartRenderer.tsx:
##########
@@ -434,9 +508,15 @@ function ChartRendererComponent({
[handleOnContextMenu, state.inContextMenu],
);
+ // Read through a ref so the callback, and the hooks passed to the chart,
+ // keep their identity when the form data changes. A new hooks object makes
+ // the plugin transform and redraw the chart, which a filter change would
+ // otherwise do under the spinner as soon as its query starts.
+ const dataMaskSourceRef = useRef(latestQueryFormData ?? formData);
+ dataMaskSourceRef.current = latestQueryFormData ?? formData;
Review Comment:
Added `chart mask updates carry the selection sources of the latest query`
to `ChartRenderer.test.tsx`. It mounts with `latestQueryFormData` carrying one
set of `semantic_selection_sources`, rerenders with a different set, emits the
mask, and asserts `updateDataMask` gets the new sources and not the first
query's. Deleting the ref assignment fails it. In 75da561.
##########
superset-frontend/src/components/Chart/ChartRenderer.tsx:
##########
@@ -591,7 +671,7 @@ function ChartRendererComponent({
<ChartContextMenu
ref={contextMenuRef}
id={chartId}
- formData={currentFormData as QueryFormData}
+ formData={renderedFormData as QueryFormData}
Review Comment:
Added `builds the context menu from the form data the chart is drawn with
while it refreshes` to `ChartRenderer.refresh.test.tsx`, with the
`ChartContextMenu` mock exposing the form data it receives. It goes through
`Chart` with `DrillToDetail` on: country-grouped data is rendered, a refresh
starts with region-grouped `formData` and the same response, and the menu is
asserted to still get the country form data, then the region form data once the
new response lands. Switching the menu back to `currentFormData` fails it. In
75da561.
--
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]