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

Support for input-group with input-group-addon element #20

Closed
holtkamp opened this issue Jan 5, 2016 · 4 comments
Closed

Support for input-group with input-group-addon element #20

holtkamp opened this issue Jan 5, 2016 · 4 comments

Comments

@holtkamp
Copy link

holtkamp commented Jan 5, 2016

Context
When using TypeAhead on a search element, it would be nice to display a search icon next to the <input/> element, where this fiddle shows a few approaches on how to realize that.

Problem
When using the simplest approach: an input-group with an icon wrapped in a input-group-addon, this seems to interfere with TypeAhead.

This HTML

    <div class="input-group">
        <input class="typeahead form-control" type="text" placeholder="Search...">
        <span class="input-group-addon"><i class="fa fa-search"></i></span>
    </div>

will be transformed by TypeAhead to something like:

    <div class="input-group">
        <span class="twitter-typeahead">
            <input class="typeahead form-control" type="text" placeholder="Search...">
            <div class="tt-menu">...</div>
        </span>
        <span class="input-group-addon"><i class="fa fa-search"></i></span>
    </div>

Notice that the menu that contains the suggestion becomes part of the input-group element making it:

  • break the rounding of the left border of the <input/> element
  • overlap the <input/> element. This makes it difficult for the user to continue its search adventure.

screen shot 2016-01-05 at 12 35 00

screen shot 2016-01-05 at 12 35 12

screen shot 2016-01-05 at 12 37 50

Would it be possible to use plain CSS to prevent the menu from overlapping?

Seems to be related to:

UPDATE
As suggested in this comment adding style="float: none;" to the input element seems to resolve the overlapping issue for Safari, FireFox, Chrome, Internet Explorer 11, Microsoft Edge. Have not tested Internet Explorer < 11 yet.

@bassjobsen
Copy link
Owner

due to the position: relative of the input, try:

.tt-menu.tt-open {
  top: 34px !important;
}

@holtkamp
Copy link
Author

holtkamp commented Jan 5, 2016

mm, ok, seems to work indeed.

When looking at this part of the source code, is it possible the class tt-dropdown-menu changed to tt-menu?

It seems #12 did not completely cover #11. Also see the classname here https://github.com/twitter/typeahead.js/blob/v0.11.1/src/typeahead/www.js#L14

Instead of supporting:

  • tt-dropdown-menu for TypeAhead < 0.11
  • tt-menu for TypeAhead >= 0.11

it might be beter to release a new version which bumps the required version of TypeAhead to >=0.11?

@bassjobsen
Copy link
Owner

yes, thanks.
You're right about that. I fixed this with e691715
I also agree that the next release should support only >= -0.11

@holtkamp
Copy link
Author

holtkamp commented Jan 5, 2016

Great, thanks for the swift support.

Since this change is backwards compatible, would it justify a new release with increased patch version? 1.2.1?

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

No branches or pull requests

2 participants