Skip to content

Commit

Permalink
selection fix
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsamson7 committed Nov 4, 2024
1 parent 9c803c9 commit 7ae1e86
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@

<ng-container *ngIf="node.type === 'microfrontend'">
<span class="name">{{node.data.name}}</span>

<!-- menu -->

<button aria-label="Add" [matMenuTriggerFor]="applicationMenu" class="menu" mat-icon-button>
<mat-icon class="add" matSuffix>more_vert</mat-icon>

<mat-menu #applicationMenu="matMenu">
<button mat-menu-item (click)="triggeredMenu(node, 'delete')">Delete</button>
</mat-menu>
</button>
</ng-container>

<!-- microfrontend version -->
Expand All @@ -59,7 +69,7 @@

<button aria-label="Add" [matMenuTriggerFor]="applicationMenu" class="menu" mat-icon-button>
<mat-icon class="add" matSuffix>more_vert</mat-icon>

<mat-menu #applicationMenu="matMenu">
<button mat-menu-item (click)="triggeredMenu(node, 'delete')">Delete</button>
</mat-menu>
Expand Down Expand Up @@ -135,7 +145,7 @@

<button aria-label="Add" [matMenuTriggerFor]="applicationMenu" class="menu" mat-icon-button>
<mat-icon class="add" matSuffix>more_vert</mat-icon>

<mat-menu #applicationMenu="matMenu">
<button mat-menu-item (click)="triggeredMenu(node, 'delete')">Delete</button>
</mat-menu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class ApplicationTreeComponent implements OnInit, OnChanges {
treeControl = new NestedTreeControl<Node>(node => node.children);
dataSource = new MatTreeNestedDataSource<Node>();

selection?: Node
selection?: Node | undefined

// private

Expand Down Expand Up @@ -142,16 +142,23 @@ export class ApplicationTreeComponent implements OnInit, OnChanges {
const children = node.parent!.children!

children.splice(index, 1)
nextNode = children.length > 0 ? children[Math.max(children.length - 1, index)] : node.parent
nextNode = children.length > 0 ? children[Math.min(children.length - 1, index)] : node.parent
}
else {
const children = this.dataSource.data
children.splice(index, 1)
nextNode = children.length > 0 ? children[Math.max(children.length - 1, index)] : undefined
nextNode = children.length > 0 ? children[Math.min(children.length - 1, index)] : undefined
}

this.refreshData()

if ( nextNode )
this.treeControl.expansionModel.select(nextNode)
else
this.treeControl.expansionModel.select()

this.select(nextNode)

return nextNode
}

Expand Down Expand Up @@ -180,7 +187,7 @@ export class ApplicationTreeComponent implements OnInit, OnChanges {
return node
}

select(node: Node) {
select(node: Node | undefined) {
this.selection = node

this.onSelectionChange.emit(node)
Expand Down

0 comments on commit 7ae1e86

Please sign in to comment.