-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Typeahead positioning bug with modals, scrolling and window resize #3529
Comments
The issue still exists in the latest version. |
Able to reproduce with latest 2.2.2-wip as well (by copying and pasting the docs' typeahead into the example modal). |
This doesn't seem that hard to fix ... The problem isn't because the menu is "fixed", the problem is that the position of the menu is "relative" to the location that input was at when it was shown. It can be "fixed" with the addition of this css to the menu: position: fixed; However, if you have other non-modal typeaheads, this will break them. They will remained fixed if you scroll ... basically replicating the same effect you are experiencing in modals. Also, typeaheads are not really configured for a modal; if you attempt to open on in a modal, it will hide behind the modal window. You need to increase it's z-index to 1051; Since bootstrap-typeahead is altering the css everytime it shows, that is the function we need to modify. A quick hack would be to look at the element's parents to see if one of them is a modal. If so, append the z-index:1051; and the position:fixed; to it's css; we also need to modify the css positioning a bit to make fixed work right. This code change worked for me:
|
I just watched the video in the initial post and I realized that I didn't take resize into account. That is also easily fixed now. So let's start again and do this properly
b) resize
Someone else, I'm sure, can make this prettier and more efficient but this should eliminate the bugs. |
note: this will likely break things for people in the same way that doing this to tooltip did… however we think this is a better insertion model for z-index,scrolling,modal,etc. applications
fixed |
The new version of typeahed introuced another issue with the modal window. If you try the demo provided by wesley-murch (http://jsfiddle.net/cBLUL/) in the first post, the item selection is very hard to do because it depends on modal height. |
This change breaks compatibility with previous versions as we needed the typeahead appended to the body. Is it possible to make this configurable? |
This is quite easy to fix, if you copy the container logic of the Bootstrap tooltips. |
The dropdown list that appears when using
typeahead()
doesn't stick to the input when scrolling, or when resizing the window This occurs in modals, or anytime where the parent element is fixed position.Here's is a demo:
http://jsfiddle.net/cBLUL/
How to reproduce:
Expected result: Suggestion list does not move at all, but stays "glued" to the input.
Actual Result: The suggestion list moves around, sometimes off screen.
Here's a screen capture to demonstrate: http://www.screenr.com/CNR8
I found the scroll issue by accidentally using the mouse wheel while focused in an input with typeahead. I found the resize issue while producing a test case for the scroll issue.
It appears that the typeahead list is appended to
body
. This could probably be easily fixed by putting the element just after the input itself instead, or even as a last child of the parentform
(or just outside the parent form) so as not to mess up any CSS or JS that relies on certain adjacent elements being in place...On second thought, not every input will have a parent form (should, but may not in the wild), and as mentioned, putting the element in the DOM anywhere else could cause other bugs, so I'm not sure that would be a real solution.
The text was updated successfully, but these errors were encountered: