1
0
mirror of https://github.com/django/django.git synced 2025-10-27 07:36:08 +00:00

Fixed #36423 -- Prevented filter_horizontal buttons from intercepting form submission.

In the admin's filter_horizontal widget, optional action buttons like
"Choose all", "Remove all", etc. were changed from `<a>` to `<button>`
elements in #34619, but without specifying `type="button"`. As a result,
when pressing Enter while focused on a form input, these buttons could
be triggered and intercept form submission.

Explicitly set `type="button"` on these control buttons to prevent them
from acting as submit buttons.

Thanks Antoliny Lee for the quick triage and review.

Regression in 857b1048d5.
This commit is contained in:
Blayze
2025-05-28 11:22:29 -07:00
committed by nessita
parent 1a74434399
commit 90429625a8
5 changed files with 56 additions and 4 deletions

View File

@@ -72,7 +72,8 @@ Requires core.js and SelectBox.js.
selector_available,
interpolate(gettext('Choose all %s'), [field_name]),
'id', field_id + '_add_all',
'class', 'selector-chooseall'
'class', 'selector-chooseall',
'type', 'button'
);
// <ul class="selector-chooser">
@@ -83,14 +84,16 @@ Requires core.js and SelectBox.js.
quickElement('li', selector_chooser),
interpolate(gettext('Choose selected %s'), [field_name]),
'id', field_id + '_add',
'class', 'selector-add'
'class', 'selector-add',
'type', 'button'
);
const remove_button = quickElement(
'button',
quickElement('li', selector_chooser),
interpolate(gettext('Remove selected %s'), [field_name]),
'id', field_id + '_remove',
'class', 'selector-remove'
'class', 'selector-remove',
'type', 'button'
);
// <div class="selector-chosen">
@@ -142,7 +145,8 @@ Requires core.js and SelectBox.js.
selector_chosen,
interpolate(gettext('Remove all %s'), [field_name]),
'id', field_id + '_remove_all',
'class', 'selector-clearall'
'class', 'selector-clearall',
'type', 'button'
);
from_box.name = from_box.name + '_old';