fix(editor): Fix inifnite loading in Resource Locator Dropdown under certain conditions (#16773)

This commit is contained in:
Milorad FIlipović
2025-07-01 10:57:18 +02:00
committed by GitHub
parent 06f49c294a
commit 8e62c80d48

View File

@@ -656,9 +656,13 @@ function loadResourcesDebounced() {
}
function setResponse(paramsKey: string, response: Partial<IResourceLocatorQuery>) {
// Force reactivity by creating a completely new cached responses object
const existingResponse = cachedResponses.value[paramsKey] || {};
const newResponse = { ...existingResponse, ...response };
cachedResponses.value = {
...cachedResponses.value,
[paramsKey]: { ...cachedResponses.value[paramsKey], ...response },
[paramsKey]: newResponse,
};
}
@@ -729,19 +733,28 @@ async function loadResources() {
const response = await nodeTypesStore.getResourceLocatorResults(requestParams);
setResponse(paramsKey, {
const responseData = {
results: (cachedResponse?.results ?? []).concat(response.results),
nextPageToken: response.paginationToken ?? null,
loading: false,
error: false,
});
};
// Store response under the original key to prevent cache pollution
setResponse(paramsKey, responseData);
// If the key changed during the request, also store under current key to prevent infinite loading
const currentKey = currentRequestKey.value;
if (currentKey !== paramsKey) {
setResponse(currentKey, responseData);
}
if (params.filter && !hasCompletedASearch.value) {
hasCompletedASearch.value = true;
trackEvent('User searched resource locator list');
}
} catch (e) {
setResponse(paramsKey, {
const errorData = {
loading: false,
error: true,
errorDetails: {
@@ -750,7 +763,16 @@ async function loadResources() {
httpCode: e.httpCode,
stackTrace: e.stacktrace,
},
});
};
// Store error under the original key
setResponse(paramsKey, errorData);
// If the key changed during the request, also store under current key to prevent infinite loading
const currentKey = currentRequestKey.value;
if (currentKey !== paramsKey) {
setResponse(currentKey, errorData);
}
}
}