material icon indicating copy to clipboard operation
material copied to clipboard

select: md-select-menu positioned above control when options are async

Open fridolin-koch opened this issue 11 years ago • 35 comments

I'm using the async variant of md-select. Instead of the menu appearing directly over the md-select it appears a few pixels above. The bug only occurs if it contains only a few elements.

screen shot 2015-10-29 at 18 37 00

This bug seems to be related to my layout, am I using the containers wrong or is this a bug?

I've created a codepen http://codepen.io/anon/pen/VvdZYx

fridolin-koch avatar Oct 29 '15 17:10 fridolin-koch

+1

p-mcgowan avatar Feb 22 '16 22:02 p-mcgowan

+1 My work around for opening below the input is:

$provide.decorator('$mdSelect',['$delegate','$timeout','$interval',          function($delegate,$timeout,$interval) {
            var origShow = $delegate.show;
            var stop;
            $delegate.show = function(){
                var onShow = origShow.apply(this, arguments);
                onShow.then(function(){
                    $interval.cancel(stop);
                    stop = undefined;
                });
                var selectInput = arguments[0].target;
                var selectDropDown = arguments[0].element;
                //angular.element(selectDropDown[0]).find('md-select-menu')[0].style.display = 'none';
                $timeout(function(){
                    var boundings = selectInput.getBoundingClientRect();
                    selectDropDown[0].style.left = boundings.left + "px" ;
                    selectDropDown[0].style.top = (boundings.top + boundings.height) + "px";
                    var dropDownBoundings = selectDropDown[0].getBoundingClientRect();
                    if(dropDownBoundings.width < boundings.width){
                        selectDropDown[0].style.width = boundings.width + "px";
                    }
                    //angular.element(selectDropDown[0]).find('md-select-menu')[0].style.display = '';
                    stop = $interval(function(){
                        selectDropDown[0].style.left = boundings.left + "px" ;
                        selectDropDown[0].style.top = (boundings.top + boundings.height) + "px";
                    },13);
                },60);
                return onShow;
            };

            return $delegate;
        }]);

macdosi avatar Feb 28 '16 16:02 macdosi

The issue still seems to be persist in 1.0.5. The dropdowns are pretty inconsistent.

jayeshanandani avatar Feb 28 '16 16:02 jayeshanandani

Can confirm this issue, it seems stable when it's about 4-5 items but when it's 10+ it shoots up to the top

shaysegev avatar Mar 06 '16 16:03 shaysegev

Issue exists in 1.0.7 after loading items from async call. .md-select-menu-container breaks outside of container and spans entire page.

davidtmnolan avatar Apr 05 '16 22:04 davidtmnolan

The issue still exists in latest master version. It makes select options unclickable due to the wrong positioning.

jayeshanandani avatar Apr 21 '16 02:04 jayeshanandani

@ThomasBurleson Is this issue open to PR?

jayeshanandani avatar Apr 21 '16 02:04 jayeshanandani

In version 1.0.6 i have the same problem, there is way to fix this ? image

SzymonPawlak avatar Jul 08 '16 08:07 SzymonPawlak

I have the same issue in angular-material v1.1.1, it appears only when I scroll the window to bottom. suggest any fix.

haneefatel avatar Sep 24 '16 07:09 haneefatel

Same issue here on v1.1.1 as @haneefatel. If i put a md-menu inside of a dialog box, it jumps out of place if i scroll to the bottom of the list to select something

Edit: I decided to revert back to regular <select></select> elements for dialog boxes only and used this Codepen to keep it looking nice: http://codepen.io/bephf/pen/ogNBYW

sdawson26 avatar Oct 06 '16 14:10 sdawson26

@haneefatel Had the same issue, Modified macdasi provider so it forces dropdown go upward when it's close to bottom of the page.

Khomitskyi avatar Oct 10 '16 10:10 Khomitskyi

+1

nicolac18 avatar Nov 07 '16 16:11 nicolac18

+1

sdawson26 avatar Nov 09 '16 16:11 sdawson26

till the day

matheushf avatar Mar 14 '18 21:03 matheushf

This seems to be working fine in 1.1.7 (and possibly a few versions prior to that). Here's a CodePen demo of that.

Splaktar avatar Mar 15 '18 01:03 Splaktar