mikebridge commented on code in PR #45649:
URL: https://github.com/apache/superset/pull/45649#discussion_r4402787899
##########
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:
Fixed in 9ec7609534. When a pending save succeeds, the modal now calls the
latest `onCreated`/`onUpdated` callbacks, kept in refs that track the current
props. The create and edit tests each save with a filter-A callback, cancel,
rerender with a filter-B callback, and confirm that only B's refresh runs. Both
tests failed before the change and pass with it.
--
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]