I'm currently working on an Angular application using Angular Material, and I've encountered a significant issue with the height of my tab content. While I have experience with HTML, CSS, and JavaScript, this is my first venture into Angular development.
Within my app, I am utilizing the MatSidenav component, which contains a MatTab component that dynamically loads various components into new tabs. Although this functionality works as intended, I am facing challenges with the content displayed in certain tabs, particularly those that fetch data from a REST service after the tab has been created.
To showcase the problem I'm experiencing, I have created a StackBlitz demo based on my actual application.
Upon navigating to "Test One" from the menu, only the buttons at the top are visible. Clicking the "Get Data" button populates the BehaviorSubject used by the data table (AgGrid), simulating a REST call similar to what my real app does. The data displays correctly, but one of the container elements (which I cannot pinpoint) does not expand properly, causing the table to remain hidden.
"Test Two," on the other hand, demonstrates a tab with static content that appears as expected (similar to the Home tab).
I have included a button that toggles the height property of the container div for the table between 500px and blank. However, I require the height to adjust dynamically based on the remaining viewport space, rather than a fixed value. Unfortunately, attempts to manipulate the dynamicHeight property of mat-tab-group or utilize flexbox settings have not yielded successful results due to varying content heights within different tabs.
The issue persists not only with the AgGrid table but also with a tab containing Google Maps. While I suspect that the problem arises from changing content post-rendering, I find it perplexing that CSS adjustments do not reflect these changes accordingly.
Currently, my makeshift solution involves using JavaScript to set element heights within ngAfterViewInit and binding a window resize event. This approach feels somewhat inelegant and necessitates applying the same workaround to all components loaded into tabs, rather than solely focusing on the problematic areas.
Your assistance in resolving this matter would be immensely appreciated.