New Metronic Docs!Added Integration Docs with Starter Kits Apps for Laravel, Laravel Livewire, Angular, Vue, Symfony, Blazor Server, Django & Flask & more
Browse Docs

KTSelect Issue


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.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (8)


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
}


We will update the select component to dynamically attach to any element by providing the selector.

dropdownContainer: '.modal'


Are you using KTUI only or with Metronic?

Thanks



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:

  • Try using dropdownContainer: 'body' when initializing KTSelect. That moves the dropdown out of the modal container so it isn’t clipped.
  • Also set a higher dropdownZindex so the dropdown stays above the modal overlay.


Extra tips:

  • Check that the modal doesn’t have overflow or clipping styles interfering with the select input.
  • If you’re adding options dynamically, trigger KTSelect’s refresh/rerender so both dropdown and input update.
  • Use dev tools to confirm the option is being applied in the DOM. If yes but not visible, it’s likely CSS/z-index.


It’s kind of like how games keep menus visible even with overlays — updates and layering matter a lot. That’s why titles like subwaysurfersapks.com stay smooth to play: regular updates make sure nothing feels “stuck” or out of place.

Do you think KT will push a patch for this soon, or is it more of a manual fix?

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
}


Alternative approach if you're using data attributes:


<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.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(