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

Search doesn't appear if select is at top of the page #1

Closed
rbleuse opened this issue Mar 3, 2018 · 8 comments
Closed

Search doesn't appear if select is at top of the page #1

rbleuse opened this issue Mar 3, 2018 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@rbleuse
Copy link

rbleuse commented Mar 3, 2018

Hi,
There is an UI issue when the select panel is at the top of the screen (in your stackblitz example, remove the header).
The problem is that the search feature doesn't appear because the select panel is not positioned depending on the search height.

See this stackblitz :
https://stackblitz.com/edit/github-5phju9?file=src/app/app.component.html

@macjohnny macjohnny added bug Something isn't working feature New feature or request help wanted Extra attention is needed question minor and removed feature New feature or request question labels Mar 5, 2018
@macjohnny
Copy link
Member

Hi @spanja
Thanks for your issue.
The problem you describe is kind of a known issue, or at least I didn't find an easy way to solve this.

Currently, in https://github.com/bithost-gmbh/ngx-mat-select-search/blob/master/src/app/mat-select-search/mat-select-search.component.scss#L51 we shift the options overlay by -50px, i.e. the height of the search input field, since MatSelect will place the overlay according to the options it contains, but not any other content, it does not take into account the search input field. The shift is to have the panel open with the currently selected option at the position of the select / current mouse position.
See also https://github.com/angular/material2/blob/master/src/lib/select/select.ts#L1011

As a workaround, you can manually override e.g. with

.cdk-overlay-pane-select-search {
  margin-top: 0px;
}

but this results in a an offset of the currently selected option from the cursor position of 50px.

@macjohnny
Copy link
Member

this issue can also occur when placing the select box somewhere on the page and scrolling it to the top edge of the viewport.

@macjohnny macjohnny removed the minor label Mar 16, 2018
@maxencefrenette
Copy link

For anybody alse who's having that problem, I recommend the disableOptionCentering option on the <mat-select> https://material.angular.io/components/select/api .

@macjohnny
Copy link
Member

@maxencefrenette thanks for sharing a solution!
would you want to file a PR to add a note to the Readme (e.g. as a subheading in the How to use it? section? I think then we could close this issue.

macjohnny added a commit that referenced this issue Jul 12, 2018
macjohnny added a commit that referenced this issue Jul 12, 2018
@macjohnny
Copy link
Member

@maxencefrenette I added your workaround to the https://github.com/bithost-gmbh/ngx-mat-select-search/blob/master/README.md#known-problems--solutions
I guess so far there is no better solution due to the way panel positioning is handled in material.

@macjohnny
Copy link
Member

With the release 1.5.0 it is possible to place <ngx-mat-select-search> inside a <mat-option> element.
This prevents the search field being placed outside of the visible viewport.
Thanks to @hanuhimanshu for proposing this solution.

@ziaKhan1995
Copy link

I faced the same issue. The reason is that NgxMatSelectSearchModule was imported but not included in imports array.

@macjohnny
Copy link
Member

@ziaKhan1995 can you open aseparate issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants