Skip to content

Commit f72c6d5

Browse files
committed
wip
1 parent 5938c35 commit f72c6d5

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

src/resources/assets/css/common.css

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,11 @@ div[id$="_wrapper"] .dt-processing {
126126

127127
/* Ensure Select2 dropdowns are visible and properly positioned in all contexts */
128128
/* Bootstrap modals use z-index 1050-1055, so Select2 needs to be higher */
129-
.select2-container--open .select2-dropdown,
130-
.select2-dropdown {
129+
.select2-in-modal-repeatable .select2-dropdown {
131130
z-index: 1060 !important;
132131
position: fixed !important;
133132
}
134133

135-
/* When Select2 is inside a modal, use absolute positioning to follow scroll */
136-
.modal .select2-container--open .select2-dropdown,
137-
.modal .select2-dropdown {
138-
z-index: 1060 !important;
139-
position: absolute !important;
140-
}
141-
142134
.navbar-filters {
143135
min-height: 25px;
144136
border-radius: 0;

src/resources/views/crud/components/dataform/common_js.blade.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,41 @@ function handleFocusOnSelect2Field(firstField){
8484
setTimeout(() => document.querySelector('.select2-container--open .select2-search__field').focus(), 100);
8585
});
8686

87+
// When Select2 opens inside a repeatable row that is itself inside a modal,
88+
// add a specific class to the open container so CSS/positioning logic can target it.
89+
// Also remove the class on close.
90+
$(document).on('select2:open', function(e) {
91+
// The event target will be the original select element
92+
try {
93+
var $select = $(e.target);
94+
var $repeatable = $select.closest('.repeatable-element');
95+
var $modal = $select.closest('.modal');
96+
97+
if ($repeatable.length && $modal.length) {
98+
// Wait briefly for Select2 to render the dropdown container
99+
setTimeout(function() {
100+
var $openContainer = $('.select2-container--open');
101+
$openContainer.addClass('select2-in-modal-repeatable');
102+
}, 0);
103+
}
104+
} catch (err) {
105+
// fail silently
106+
}
107+
});
108+
109+
$(document).on('select2:close', function(e) {
110+
try {
111+
var $select = $(e.target);
112+
var $repeatable = $select.closest('.repeatable-element');
113+
var $modal = $select.closest('.modal');
114+
115+
if ($repeatable.length && $modal.length) {
116+
// remove the class from any open containers
117+
$('.select2-container--open').removeClass('select2-in-modal-repeatable');
118+
}
119+
} catch (err) {
120+
// fail silently
121+
}
122+
});
123+
87124
@endverbatim

0 commit comments

Comments
 (0)