Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

autocomplete: shows dropdown on top even when there is no room #10859

Closed
begemott opened this issue Aug 18, 2017 · 11 comments · Fixed by #11575 or #11629
Closed

autocomplete: shows dropdown on top even when there is no room #10859

begemott opened this issue Aug 18, 2017 · 11 comments · Fixed by #11575 or #11629
Assignees
Labels
for: internal contributor The team will address this issue and community PRs are not requested. has: Pull Request A PR has been created to address this issue P3: important Important issues that really should be fixed when possible. resolution: fixed severity: inconvenient type: bug ux: integration
Milestone

Comments

@begemott
Copy link

begemott commented Aug 18, 2017

Actual Behavior:

  • What is the issue? *
    Sometimes the autocomplete dropdown will be shown at the top of an input, partially out of the screen, but it should be bottom position in this case.

CodePen (or steps to reproduce the issue): *

Steps to reproduce

  • The md-autocomplete should not have md-dropdown-position (position should be determined automatically)
  • The md-autocomplete's input should be placed below the screen, so the window should be scrolled to see the input.
  • Scroll the window until the md-autocomplete's input gets the top of the window
  • Focus the input
  • The autocomplete dropdown will be shown at the top of input partially out of the screen, but should be at the input's bottom

AngularJS Versions: *

  • AngularJS Version: 1.5.5
  • AngularJS Material Version: 1.1.4

Additional Information:

  • Browser Type: * Chrome, FF, IE
  • Browser Version: * Chrome - 60.0.3112.90, FF - 54.0.1, IE - 11
  • OS: * Window 7

Another issue reproduced on FF and IE only - after closing the dropdown the window is scrolled to the window top.

@AkhilNaidu09
Copy link

I have a work around for the last point (winodw is scrolling to top after closing drop down)

Issue : Another issue reproduced on FF and IE only - after closing the dropdown the window is scrolled to the window top.

_:-ms-input-placeholder, :root {
  body[style] {
    position: inherit !important;
    top: inherit !important;
    width: inherit !important;
  }

  .md-click-catcher.md-wbTheme-theme {
    height: 100%;
    position: fixed;
    width: 100%;
  }
}

@AkhilNaidu09
Copy link

AkhilNaidu09 commented Sep 11, 2017

If you want to open options list always downwards, this is the workaround we have up to now.

open angular-material.js file

change shouldOpenAroundTarget to True,

function calculateMenuPositions(scope, element, opts) {
      var
        containerNode = element[0],
        targetNode = opts.target[0].children[0], // target the label
        parentNode = $document[0].body,
        selectNode = opts.selectEl[0],
        contentNode = opts.contentEl[0],
        parentRect = parentNode.getBoundingClientRect(),
        targetRect = targetNode.getBoundingClientRect(),
         shouldOpenAroundTarget = true,

@alexthewilde
Copy link

Another effective workaround is to simply use md-dropdown-position="bottom".

@areeb5
Copy link

areeb5 commented Nov 17, 2017

this way is justing putting the dropdown elements below the control(md-autocomplete), but that list is very compact, hardly only 2items is showing as i have attached snapshot, kindly any one help me in this,
i have also applied css to body hard coded (height:auto !important;) but that also disturbing the scroll of application.
i422 cimgpsh_orig

@Splaktar Splaktar changed the title md-autocomplete shows dropdown on incorrect position autocomplete: shows dropdown in incorrect position Mar 1, 2018
@Splaktar Splaktar self-assigned this Mar 1, 2018
@Splaktar
Copy link
Member

Splaktar commented Mar 1, 2018

The window jumping to the top on selection has been fixed. Updated CodePen showing the fix in 1.1.7.

But the popup is still displaying on top, even when there is no room on the screen to display it. It also disables the window's scroll, so you can't scroll up without closing the popup. If a hard coded md-dropdown-position is not defined, it should choose the option which fits the popup the best.

@Splaktar Splaktar changed the title autocomplete: shows dropdown in incorrect position autocomplete: shows dropdown on top even when there is no room Mar 1, 2018
@Splaktar Splaktar added this to the 1.1.9 milestone Mar 1, 2018
@Splaktar Splaktar added type: bug ux: integration needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community needs: Pull Request severity: inconvenient P3: important Important issues that really should be fixed when possible. labels Mar 1, 2018
@Splaktar Splaktar modified the milestones: 1.1.9, 1.1.10 Apr 19, 2018
@Splaktar Splaktar modified the milestones: 1.1.10, 1.1.11 Jun 19, 2018
@Splaktar Splaktar modified the milestones: 1.1.11, 1.1.12 Sep 10, 2018
@Suvarnni
Copy link

Suvarnni commented Oct 4, 2018

in which release we can expect this issue fix, because I'm facing a similar issue like this in IE11 browser.

@Splaktar
Copy link
Member

Splaktar commented Nov 9, 2018

@Suvarnni we would like to get it into 1.1.12. If you are interested in taking a shot at fixing it, I can help review your PR.

@balajiprasadb
Copy link

Hi @Splaktar, I'm facing the same issue. When can we expect this to be fixed?

@marosoft
Copy link
Contributor

marosoft commented Jan 3, 2019

Hi @Splaktar

The problem is with top and bottom values of root being negative:
screenshot 2019-01-03 at 15 02 38

I made some changes to fix the problem. Please check this CodePen. I am displaying some debug data in the console.

These are my code changes:
screenshot 2019-01-03 at 15 29 46

This is a code line I changed.

top and bottom values of vrect are relative to the viewport.

@Splaktar Splaktar added needs: Pull Request and removed needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community labels Jan 3, 2019
@Splaktar
Copy link
Member

Splaktar commented Jan 3, 2019

@marosoft thank you for looking into that. The fix looks good to me. Please submit a PR.

marosoft added a commit to marosoft/material that referenced this issue Jan 3, 2019
Don't use the bounding rectangles of a document body to determine
the position of the dropdown.
Top and bottom values of the snap element are relative to the viewport,
which is enough to decide about the position of the dropdown.

Fixes angular#10859
@Splaktar Splaktar modified the milestones: 1.1.12, 1.1.13 Jan 3, 2019
@Splaktar Splaktar added has: Pull Request A PR has been created to address this issue and removed needs: Pull Request labels Jan 3, 2019
mmalerba pushed a commit that referenced this issue Jan 5, 2019
Don't use the bounding rectangles of a document body to determine
the position of the dropdown.
Top and bottom values of the snap element are relative to the viewport,
which is enough to decide about the position of the dropdown.

Fixes #10859
Splaktar added a commit that referenced this issue Feb 1, 2019
This reverts commit 46e08e5

Related to #11626. Related to #11575. Related to #10859.
@Splaktar
Copy link
Member

Splaktar commented Feb 1, 2019

The fix for this was reverted in PR #11626 due to a regression that it caused.

PR #11629 has been posted to bring this fix back, but it still needs reproduction steps for the regression before it can be investigated and fixed.

@Splaktar Splaktar reopened this Feb 1, 2019
@Splaktar Splaktar added for: internal contributor The team will address this issue and community PRs are not requested. and removed for: external contributor labels Feb 1, 2019
Splaktar added a commit that referenced this issue Feb 1, 2019
jelbourn pushed a commit that referenced this issue Feb 8, 2019
Splaktar added a commit that referenced this issue Mar 10, 2019
fix horizontal alignment edge cases
fix $mdUtil.getViewportTop to handle when body scrolling is disabled

Fixes #11656. Relates to #10859, #11629, #11575.
Splaktar added a commit that referenced this issue Mar 10, 2019
fix horizontal alignment edge cases
fix $mdUtil.getViewportTop to handle when body scrolling is disabled

Fixes #11656. Relates to #10859, #11629, #11575.
Splaktar added a commit that referenced this issue Mar 18, 2019
fix horizontal alignment edge cases
fix $mdUtil.getViewportTop to handle when body scrolling is disabled

Fixes #11656. Relates to #10859, #11629, #11575.
andrewseguin pushed a commit that referenced this issue Mar 20, 2019
…1670)

fix horizontal alignment edge cases
fix $mdUtil.getViewportTop to handle when body scrolling is disabled

Fixes #11656. Relates to #10859, #11629, #11575.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
for: internal contributor The team will address this issue and community PRs are not requested. has: Pull Request A PR has been created to address this issue P3: important Important issues that really should be fixed when possible. resolution: fixed severity: inconvenient type: bug ux: integration
Projects
None yet
8 participants