question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

virtual-scroll inside mat-select new values not visible & big space

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

cdk-virtual-scroll-viewport inside a mat-select or mat-autocomplete should align with the overlay panel.

<mat-form-field>
    <mat-select placeholder="State">
	<cdk-virtual-scroll-viewport [itemSize]="10">
      	  <mat-option *cdkVirtualFor="let state of states" [value]="state">
             {{state}}
          </mat-option>
	</cdk-virtual-scroll-viewport>
   </mat-select>
</mat-form-field>

What is the current behavior?

When scrolled cdkVirtualFor does not seem to add more elements and moreover shows a big space from last element of the initial set of items to the end.

What are the steps to reproduce?

https://stackblitz.com/edit/angular-h4xptu-dgjd87?file=app/select-reset-example.html

What is the use-case or motivation for changing an existing behavior?

  • Occasionally I run into scenarios where the items in the list are too many and makes the page unresponsive.

  • Seem-less integration of cdk-virtual-scroll-viewport with other components.

  • mat-select essentially can handle any number of elements when this works.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular CLI: 6.1.5
Node: 10.0.0
OS: win32 x64
Angular: 6.1.4
... animations, common, compiler, core, forms, http
... platform-browser, platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.7.5
@angular-devkit/build-angular      0.7.5
@angular-devkit/build-ng-packagr   0.7.5
@angular-devkit/build-optimizer    0.7.5
@angular-devkit/build-webpack      0.7.5
@angular-devkit/core               0.7.5
@angular-devkit/schematics         0.7.5
@angular/cdk                       6.4.7
@angular/cdk-experimental          6.4.7
@angular/cli                       6.1.5
@angular/compiler-cli              6.1.7
@angular/flex-layout               6.0.0-beta.17
@angular/language-service          6.1.7
@angular/material                  6.4.7
@ngtools/webpack                   6.1.5
@schematics/angular                0.7.5
@schematics/update                 0.7.5
rxjs                               6.2.2
typescript                         2.9.2
webpack                            4.9.2

Is there anything else we should know?

Great work

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:10
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
StefanoLucchicommented, Dec 10, 2018

Also cdk-virtual-scroll-viewport inside a mat-menu doesn’t work properly. Sometimes, blank space appears with mouse wheel scrollling. StackBlitz

5reactions
yogeshgadgecommented, Sep 12, 2018

Workaround:-

https://stackblitz.com/edit/angular-h4xptu-zyj4yh?file=styles.css

Added class virtual-scroll to mat-select

<mat-select placeholder="State" class="virtual-scroll">

and add global styles as below:-

In styles.css add

.mat-select-panel.virtual-scroll {
    max-height: 100% !important;
    overflow: inherit !important;
}
.mat-select-panel .cdk-virtual-scroll-viewport {
   max-height: 240px !important;
}

.mat-select-panel .cdk-virtual-scroll-content-wrapper {
    position: inherit !important;  
    top: inherit !important;  
    left: 0; 
}

I think the real solution would be that somehow mat-select-panel ideally starts behaving like cdk-virtual-scroll-viewport which is what this workaround crudely tries to do in totality by negating scrolling properties of mat-select-panel and having cdk-virtual-scroll-viewport take charge.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cdk virtual-scroll inside mat-select for mat-option
The virtual scroll viewport needs a size in order to know, how big the scroll container must be. This can be done by...
Read more >
Access Angular Material's MatSelect Options Panel Container
In this article we're going to explore how you can programmatically access the Angular Material Select panel, without doing strange global ...
Read more >
Make Scroll Always Show In Material Select - ADocLib
cdk-virtual-scroll-viewport inside a mat-select or mat-autocomplete shows a big space from last element of the initial set of items to the end.
Read more >
Virtual scrolling in a mat-select dropdown using a nested form ...
What and why's of Virtual Scrolling in Angular it is!! ... need to load a huge data set of values to a select...
Read more >
Getting to Know the Angular CDK Virtual Scroll Feature
As a developer, you've probably had to implement a big list or table for your ... An initial implementation of virtual scrolling is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found