sadpandajoe commented on code in PR #45649:
URL: https://github.com/apache/superset/pull/45649#discussion_r4397490204
##########
superset-frontend/src/features/semanticLayers/SemanticLayerModal.tsx:
##########
@@ -333,32 +373,45 @@ export default function SemanticLayerModal({
};
const handleCreate = async () => {
+ saveRequestRef.current += 1;
+ const request = saveRequestRef.current;
setSaving(true);
try {
if (isEditMode && semanticLayerUuid) {
await SupersetClient.put({
endpoint: `/api/v1/semantic_layer/${semanticLayerUuid}`,
jsonPayload: { name, configuration: formData },
});
+ if (request !== saveRequestRef.current) {
+ // Cancel refreshed the parent before the update committed.
+ onUpdated?.();
+ return;
+ }
addSuccessToast(t('Semantic layer updated'));
} else {
await SupersetClient.post({
endpoint: '/api/v1/semantic_layer/',
jsonPayload: { name, type: selectedType, configuration: formData },
});
+ // The server created the layer even if this dialog was closed. Only
+ // the parent may refresh the picker; stale dialog UI remains ignored.
+ onCreated?.();
Review Comment:
`onCreated` (and `onUpdated` at line 387) is read from props when
`handleCreate` starts, so the late-save refresh runs the callback from the
render where Save was clicked. In `DatabaseList` that is `combinedRefreshData`,
which closes over `lastFetchConfig` at that render. If a user clicks Save under
filter A, cancels, switches the list to filter B, and the POST/PUT then
succeeds, the callback refetches with filter A and overwrites B's rows and
count while the controls still show B. Would reading the callbacks through a
ref that tracks the latest props avoid replaying the stale list config?
--
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]