When I manually add options to the select via JS, they are displayed correctly in the dropdown, but when I click, I do not see the selected items in the select input.
The issue happens only if the select is in a modal.
The option in the dropdown menu is not selected, but when printing the selected values, it appears.
Hi,
We have a weekly Metronic update. This issue fix will be included with this week's updates.
Thanks
Hi
Looking at the code, I can see the problem. The body attachment is hardcoded to body element.
if (containerSelector === "body") {
return document.body; // This breaks modal attachment
}
Hi,
I use Metronic with KTUI.
When will this fix be released?
Its really annoying to have to use a select without style.
Ty
Hi,
We have a weekly Metronic update. This issue fix will be included with this week's updates.
Thanks
Hey — saw your KTSelect issue. Looks like when adding options via JS inside a modal, the dropdown shows the new items but selecting them doesn’t update the visible input.
What I’ve found so far:
dropdownContainer: 'body'
when initializing KTSelect. That moves the dropdown out of the modal container so it isn’t clipped.dropdownZindex
so the dropdown stays above the modal overlay.overflow
or clipping styles interfering with the select input.Hi
Sorry for the delay in response. You can configure KTSelect with dropdownContainer: 'body':
// When initializing KTSelect in a modal
const selectElement = document.querySelector("#yourSelectId");
const ktSelectInstance = new KTSelect(selectElement, {
dropdownContainer: "body", // This moves the dropdown to document.body
dropdownZindex: 9999, // Ensure it"s above modal z-index
debug: true // Optional: for troubleshooting
}
<select data-kt-select="{"dropdownContainer": "body", "dropdownZindex": 9999}">
<!-- your options -->
</select>
Adding dropdownContainer: ‘body’ solves the above problems, but on the other hand, the dropdown is no longer attached to the modal.