-
Notifications
You must be signed in to change notification settings - Fork 3.4k
md-virtual-repeat scroll size not updated #4435
Comments
Possibly related to #4308? |
Did the auto-complete item window change from "normal" repeat to "virtualRepeat"? from 10.1 to 11? and if so is there a way to force non-virtualRepeat? |
Feel free to commit the relevant change in the PR if you can find them easily. Need to learn how to do a PR correctly. :) |
I've been using the following fix without problems: I would submit a PR, but I was declined permission. |
Unless I'm misunderstanding the bug, it seems like this is working for me on HEAD (Fixed by #5908?). @bluebirdtech Can you confirm? |
@bluebirdtech Closing this issue now, let us know if there's still a problem. |
I am using 1.0.0 RC4 and I am still getting it.
|
@tonyawad88 Do you see the problem with RC5? |
@jelbourn It is still a bug in RC5. I just tried it. |
@jelbourn I might have found something. In virtualRepeat.js, there's a variable NUM_EXTRA. If we change it from 3 to 8, it seems to fix part of the problem. When there are 5 or more items in the suggestion list, they are displayed properly. But when it's less than 5 it still doesn't autoshrink.
|
@jelbourn Was having the same issue. VirtualRepeatContainerController.prototype.sizeScroller_ = function(size) {
var dimension = this.isHorizontal() ? 'width' : 'height';
var crossDimension = this.isHorizontal() ? 'height' : 'width';
// If the size falls within the browser's maximum explicit size for a single element, we can
// set the size and be done. Otherwise, we have to create children that add up the the desired
// size.
if (size < MAX_ELEMENT_SIZE) {
this.sizer.innerHTML = '';
this.sizer.style[dimension] = size + 'px';
}
... |
@MigFerreira I tried just adding that portion: if (size < MAX_ELEMENT_SIZE) {
this.sizer.innerHTML = '';
this.sizer.style[dimension] = size + 'px';
} |
@tonyawad88 in my case the bug was using directly virtual repeat and not autocomplete. I tried recreating your case in codepen but could get the issue. If you could create a pen i will gladly help you out. |
@bluebirdtech Have you found any workarounds for this ? The virtual repeat container doesn't autoshrink when the number of items have a height less than the original max-height passed by the autocomplete: var ITEM_HEIGHT = 41,
MAX_HEIGHT = 5.5 * ITEM_HEIGHT,
... Is this the bug you've been having ? Thanks |
@MigFerreira @ThomasBurleson @kseamon @jelbourn I found what is causing this issue. It's quite interesting. Problem: "material.core",
"material.components.autocomplete",
"material.components.virtualRepeat",
"material.components.chips",
... Solution Any idea what the root of this problem might be ? Do I have to include the modules in a certain order or am I missing a component that I should include? I have no warnings or errors for the missing component. Please let me know if you need more info. |
@ThomasBurleson @kseamon @jelbourn I promise this is my last post on this, sorry to bug you all. I was able to narrow it down to the root cause. Component virtualRepeat depends on component showHide. We should be throwing an error when "showHide" component is not included. Currently virtualRepeat only depends on material.core. Suggested fix to virtualRepeat.js: angular.module('material.components.virtualRepeat', [
'material.core',
"material.components.showHide",
]) I haven't done a PR before. If you send me some documents/guidance, I can help you guys out. |
@tonyawad88 Thanks for the debugging! I submitted a change with your fix. Anyone else let us know if this issue still occurs. |
@jelbourn the scrolling issue visble in the images above still occur when you have more than MAX_ELEMENT_SIZE elements then filter and get less. In this case when the size is updated the innerHTML must also be cleaned out. if (size < MAX_ELEMENT_SIZE) {
this.sizer.innerHTML = '';
this.sizer.style[dimension] = size + 'px';
} |
@MigFerreira good point. Created fix in #6087 |
If the number of items shrinks, and scrollOffset > 0, it scrolls to the top, but doesn't update the scroll size. Hence, you're left with a dirty scrollbar.
This is happening here: https://github.com/angular/material/blob/master/src/components/virtualRepeat/virtual-repeater.js#L543
Not familiar with this code, but perhaps it needs to call
this.container.setScrollSize(itemsLength * this.itemSize);
In addition to
this.container.resetScroll();
Easy fix?
The text was updated successfully, but these errors were encountered: