Describe the bug
The bug that we have found is in terms of the MatSelect component, but I believe the MatCheckbox also suffers the same issue. If you have a MatSelect component in your page it renders the options in a seperate DOM element. I am talking about the UL element, the issue comes in that it never disposes,if you navigate away from that page and then navigate back to it, it recreates the UL element, thus doing navigation a couple of times would result in having n-number of UL elements with the inner LI or Span elements. I see from the repo that a dotnetobjectreference is created for each MatSelect element that is then stored in Javascript, thus leads to the memory reference never being disposed and can cause your application to freeze. The issue gets worse when you have a couple of MatSelects in a table and each row contains one MatSelect. If you click on any MatSelect it causes each one of them to actually rerender and create a additional UL element in the DOM.
To Reproduce
Steps to reproduce the behavior:
Blazorfiddle link
You can see this behavior on the MatBlazor website as well. Click on The MatSelect menu item, then navigate away and then navigate back.
Expected behavior
The UL element in the DOM should get destroyed after using it.
Additional context
The memory leaks happens especially if the MatSelect has a List
I believe the issue to be that the UL element is getting renderes outside the
Please let me know if you need any additional information.
This seems like a huge issue that would prevent anyone from using the MatSelect in a production environment. Is there any update on when this may be addressed? I really like the MatBlazor controls and appreciate the efforts of the contributors, but it seems like alot of issues remain unresolved. It would be nice to see the existing components fixed and polished before moving on to add new components.
@chris1411 Hi! I can only speak for myself but I haven't had so much time lately since I recently became a father which occupies a great deal of my time right now :)
But to address your last sentence - I can tell you that almost all work of the contributors goes to fixing bugs or reviewing PR's. I don't think anyone (or perhaps @SamProf ) of the active contributors is developing new components.
@lindespang I totatally understand and thanks for the clarification on development efforts.
After digging into this some more, it looks like if you use the FullWidth="true" on the MatSelect, it correctly anchors the list to the select element instead of the body, and therefore disposes of the list when the MatSelect is disposed. So there is a workaroud. However it looks like the MatMenu has the same issue since they are both built on top of the same mdc-menu components, and i don't believe there is a way to anchor that element currently.
I'm not very familiar with the mdc components, but is there any reason why we would not want to anchor the list to its parent element? Seems like it would fix this issue if we make that the default behavior for both the menu and the select.
@SamProf Do you have an any answer to @chris1411 question? From what I can see in the changeset I can see that you added a condition to only anchor to parent if "Fullwidth" but otherwise anchor to body. (The proposed change from the PR was to always anchor to parent)
Any update on this?