mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
In the admin, when selecting related objects via the helpers defined in
`RelatedObjectLookups.js`, the `dismissRelatedLookupPopup` function was
attempting to access `window.relatedWindows`, which does not exist in
real execution, causing related lookup popups to remain open.
This change ensures that this code correctly accesses the module-local
`relatedWindows` by explicitly assigning it to `window.relatedWindows`.
Regression in 91bebf1adb.
Thanks Matthias Kestenholz for the report, the fix ideas, and testing.
Co-authored-by: Matthias Kestenholz <mk@feinheit.ch>
This commit is contained in:
@@ -58,9 +58,9 @@
|
||||
elem.value = chosenId;
|
||||
}
|
||||
$(elem).trigger('change');
|
||||
const index = window.relatedWindows.indexOf(win);
|
||||
const index = relatedWindows.indexOf(win);
|
||||
if (index > -1) {
|
||||
window.relatedWindows.splice(index, 1);
|
||||
relatedWindows.splice(index, 1);
|
||||
}
|
||||
win.close();
|
||||
}
|
||||
@@ -206,6 +206,7 @@
|
||||
window.dismissChangeRelatedObjectPopup = dismissChangeRelatedObjectPopup;
|
||||
window.dismissDeleteRelatedObjectPopup = dismissDeleteRelatedObjectPopup;
|
||||
window.dismissChildPopups = dismissChildPopups;
|
||||
window.relatedWindows = relatedWindows;
|
||||
|
||||
// Kept for backward compatibility
|
||||
window.showAddAnotherPopup = showRelatedObjectPopup;
|
||||
|
||||
@@ -8,7 +8,6 @@ QUnit.module('admin.RelatedObjectLookups', {
|
||||
<input type="text" id="test_id" name="test" />
|
||||
<input type="text" id="many_test_id" name="many_test" class="vManyToManyRawIdAdminField" />
|
||||
`);
|
||||
window.relatedWindows = window.relatedWindows || [];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user