html – Mat-tree horizontal scrolling. How to add it?-ThrowExceptions

Exception or error:

I have problems with horizontal scrolling. My mat-tree implementation is from here. Vertical scrolling works perfectly but horizontal doesn’t work. How to add it to my mat-tree? By using an overflow parameter I see the horizontal scrolling bar but it doesn’t work, doesn’t react to content and it is still disabled.

<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
  <mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding>
    <button mat-icon-button disabled></button>
    {{node.item}}
  </mat-tree-node>
  <mat-tree-node *matTreeNodeDef="let node; when: hasChild" matTreeNodePadding>
    <button mat-icon-button
            [attr.aria-label]="'toggle ' + node.filename" matTreeNodeToggle>
      <mat-icon class="mat-icon-rtl-mirror">
        {{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
      </mat-icon>
    </button>
    {{node.item}}
    <mat-progress-bar *ngIf="node.isLoading"
                      mode="indeterminate"
                      class="example-tree-progress-bar"></mat-progress-bar>
  </mat-tree-node>
</mat-tree>
.example-tree-progress-bar {
  margin-left: 30px;
}
How to solve:

works for me with https://github.com/angular/flex-layout/wiki/fxFlex-API, should be because of max-width=20% it sets on wrapping div:

  <div fxFlex="1 1 20%" fxLayout="row" style="overflow: scroll">
      <mat-tree fxFlex="0 0 auto" ...>
  </div>

###

have you tried adding a class to the child mat-tree-node with the style overflow:visible!important .
Here is the complete class to be added btw.

.tree-node {
   margin: 0; 
   padding: 0;
   padding-right: 1%; 
   list-style: none; 
   border: none; 
   overflow: visible !important; /* notice here*/ 
  }

Leave a Reply

Your email address will not be published. Required fields are marked *