Using orientation:auto but date picker still appears above, cut off, when there plenty of space below.
In the screenshot, the orientation is set to "auto" so we'd expect the calendar to appear below insead of cut off above:

Thanks for the bug report! It's indeed an issue and we will try to fix it soon. This is an example to show to issue
I did a workaround by changing the following line:
if (Math.max(top_overflow, bottom_overflow) === bottom_overflow)
yorient = 'top';
To:
if (Math.max(top_overflow, bottom_overflow) === bottom_overflow || scrollTop === 0)
yorient = 'top';
This is the result:
Thanks @osama9! The fix you propose is possibly also a fix for #1286, I will take a look at it later today!
Hmm there's definitely something else causing this then, as that fix hasn't solved my issue (though circumstances are probably different).
Mine still goes out of view when the orientation is set to "auto":

So something in the auto logic is missing when the picker is at the very top of a fixed-position element (a panel stuck to the side in my app). Any ideas?
:+1:
The proposed javascript workaround works fine for datepickers which open to the top (and fall off the screen) but not for ones opening to the bottom.
you can use container to solve this
$('#date-range').datepicker({
format: 'yyyy-mm-dd',
clearBtn: true,
autoclose: true,
disableTouchKeyboard: true,
inputs: $('input[name="date-range-start-date"],input[name="date-range-end-date"]').toArray(),
container: '#date-range-picker-container'
});
Alternative solution:
if (Math.max(top_overflow, bottom_overflow) === bottom_overflow && top_overflow > 0 || scrollTop > 0)
I've updated it again with a more simple
if (top_overflow > 0)
Always display calendar on top if there is space.
I've forked the fiddle example, can you test this ?
Example:
http://jsfiddle.net/asessa/pnd6e36k/
Looks promising! In my own project (behind closed doors sorry) I only see one problem: it falls behind a fixed positioned element, instead of dropping in the other direction.
Further, also in the fiddle, the little arrow is wrongly positioned. Pointing the other direction as the input field is.
Looks like the css (position-bottom / top) are inverted, updated.
http://jsfiddle.net/asessa/pnd6e36k/2/
I found a simple repro for the problem I'm having with fixed elements: using the default fixed navbar from bootstrap: http://jsfiddle.net/4hmcd1ug/
But maybe this is another bug, making it work with fixed navbars.
Do you mean this:
http://jsfiddle.net/asessa/4hmcd1ug/1/
Test with scrolling:
http://jsfiddle.net/asessa/4hmcd1ug/2/
Sorry, forgot to save: http://jsfiddle.net/4hmcd1ug/4/
Just before it should dropdown, it falls behind the navbar.

It's a z-index problem because can't retreive nav (using parents) z-index. I've set a minimum z-index of 1080, maximum z-index on bootstrap is currently 1070 used by tooltip, so this should work with any bootstrap component.
http://jsfiddle.net/asessa/4hmcd1ug/5/
Yeah. Of course.
Maybe good to pick a z-index which sits at a correct hierarchy? Above elements which are always there like a navbar but below interactive elements like a tooltip? In that way a tooltip inside the datepicker would still work.
@asessa , your fix works for me except for when I minify the javascript. If I deploy with non-minified js, it works. Not sure why that is. It was the same way with the version you didn't modify.
@richinator38 there were a few console.log used for debugging, try with this version please: http://jsfiddle.net/asessa/4hmcd1ug/6/
Didn't work.

The blue bar is a fixed navbar ? what is the current z-index ?