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

Select2 when in a modal out of position


Hi everyone,

I'm having trouble displaying a Select2 dropdown inside a modal in my project. The dropdown is always misaligned and appears outside its intended position.

I've taken a screenshot:

Using Metronic 8

Any ideas on how to solve this?


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 (5)


Hi,

Please check Metronic Select2 with Modal guide to properly use Select2 inside Modals by passing data-dropdown-parent="#kt_modal_1" to the Select2 element.

Regards,
Sean



I have follow the documentation,

So it is all configured,

<select name="business_form[country]" aria-label="Select a Country" data-control="select2" data-placeholder="Select a Country..." data-dropdown-parent="#kt_modal_add_business" class="form-select form-select-solid fw-bold select2-hidden-accessible" data-select2- tabindex="-1" aria-hidden="true" data-kt-initialized="1">

modal:
<div class="modal fade" tabindex="-1" aria-hidden="true">



I have follow the documentation, however still not working, and have tried everything to align the select2

<select name="business_form[country]" aria-label="Select a Country" data-control="select2" data-placeholder="Select a Country..." data-dropdown-parent="#kt_modal_add_business" class="form-select form-select-solid fw-bold select2-hidden-accessible" data-select2- tabindex="-1" aria-hidden="true" data-kt-initialized="1">

modal:
<div class="modal fade" tabindex="-1" aria-hidden="true">



Hi,

Is this example working for you?

Will it be possible to send us a test URL in a private reply?

Regards,
Sean


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  :(