Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (9)


HI there has this been fixed? My KTSelect is still not working on the modal even when trying the suggestions provided. Could I also ask how can I select an option using Javascript



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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(