Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #38237 - select2 search not working in modals #10456

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,11 @@ function activate_select2(container, allowClear ) {
selectAllowClear = false;
}
}
var dropdownParent = $(document.body);
if ($(this).parents('.modal').length !== 0)
dropdownParent = $(this).parents('.modal');
$(this).select2({
dropdownParent,
language: langAttr,
width: '100%',
allowClear: selectAllowClear,
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/host_edit_interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function show_interface_modal(modal_content) {
modal_window
.find('.modal-title')
.text(__('Interface') + ' ' + String(identifier));
modal_window.modal({ show: true });
modal_window.modal({ show: true , backdrop: 'static'});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow because of the select parent change, if its inside a modal, there is, a pixel in the select in the modal, that if a user clicks on at the right timing, closes the modal as its somehow outside the modal.
This makes is so the modal isnt closed on a click out side (only by clicking the X/save/cancel buttons)
other modal in the hosts page already has it $('#host-conflicts-modal').modal({ show: 'true', backdrop: 'static' });

Copy link
Member Author

@MariaAga MariaAga Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests, while running in normal, in headless mode, some how click this pixel in the second select in the interface modal, and close it


modal_window.find('a[rel="popover-modal"]').popover();
activate_select2(modal_window);
Expand Down
Loading