Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs about input-group and dropdowns #30913

Open
XhmikosR opened this issue May 27, 2020 · 6 comments
Open

Add docs about input-group and dropdowns #30913

XhmikosR opened this issue May 27, 2020 · 6 comments

Comments

@XhmikosR
Copy link
Member

If you want to use a dropdown on the button that isn't at the last element of the input group, you can do it by using multiple .input-group-appends. I mentioned about this usage in #25075, but it isn't described in the documents.

Demo: https://codepen.io/anon/pen/wNJWeL

Why need multiple .input-group-append? A .dropdown-menu must be the last child of the wrapper (.dropdown, .btn-group or an element has position: relative). This mean the following code is incorrect:

<div class="input-group">
  <input type="text" class="form-control">
  <div class="input-group-append">
    <button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown">Dropdown</button>
    <!-- dropdown-menu must be at the last of the container. -->
    <div class="dropdown-menu">
      <a class="dropdown-item" href="#">Action</a>
      <a class="dropdown-item" href="#">Another action</a>
      <a class="dropdown-item" href="#">Something else here</a>
    </div>
    <button class="btn btn-outline-secondary" type="button">Button</button>
  </div>
</div>

So, you should use multiple .input-group-appends:

<div class="input-group">
  <input type="text" class="form-control">
  <div class="input-group-append">
    <button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown">Dropdown</button>
    <div class="dropdown-menu">
      <a class="dropdown-item" href="#">Action</a>
      <a class="dropdown-item" href="#">Another action</a>
      <a class="dropdown-item" href="#">Something else here</a>
    </div>
  </div>
  <div class="input-group-append">
    <button class="btn btn-outline-secondary" type="button">Button</button>
  </div>
</div>

Originally posted by @ysds in #28150 (comment)

@XhmikosR XhmikosR changed the title If you want to use a dropdown on the button that isn't at the last element of the input group, you can do it by using multiple .input-group-appends. I mentioned about this usage in #25075, but it isn't described in the documents. Add docs about input-group and dropdowns May 27, 2020
@Ray-Aries
Copy link

Ray-Aries commented Jun 3, 2020

Hi, @XhmikosR,
This issue happen inside the .input-group-append class element only, and can't found this inside the .input-group-prepend class element. It is strange.
See #30698 (I have append some detail information)
At last, I add .rounded-0 for solve it.

@XhmikosR
Copy link
Member Author

@MartijnCuppens @ffoodd feel free to close this if it's not valid anymore

@MartijnCuppens
Copy link
Member

@XhmikosR
Copy link
Member Author

@MartijnCuppens does it still happen on v4? The issue is about v4.

@MartijnCuppens
Copy link
Member

Didn't check that indeed.

@mdo
Copy link
Member

mdo commented Jan 12, 2021

Sometimes I hate our input group lol. Updated the demo from the opening comment and there are issues with both append and prepend. https://codepen.io/emdeoh/pen/gOwBxzN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants