Browse Source

fix: some bugs for the upgrade

pull/25931/head
sumeyye 1 week ago
parent
commit
0ecd9b9698
  1. 4
      npm/ng-packs/packages/core/src/lib/directives/permission.directive.ts
  2. 2
      npm/ng-packs/packages/theme-shared/src/lib/components/breadcrumb/breadcrumb.component.html
  3. 13
      npm/ng-packs/packages/theme-shared/src/lib/components/breadcrumb/breadcrumb.component.ts
  4. 6
      npm/ng-packs/packages/theme-shared/src/lib/services/toaster.service.ts
  5. 2
      npm/ng-packs/packages/theme-shared/src/lib/tests/breadcrumb.component.spec.ts

4
npm/ng-packs/packages/core/src/lib/directives/permission.directive.ts

@ -52,7 +52,9 @@ export class PermissionDirective implements OnDestroy, OnChanges, AfterViewInit
if (!this.rendered) {
this.cdrSubject.next();
} else {
this.cdRef.detectChanges();
// Defer via queue — sync detectChanges during ApplicationRef.tick
// (e.g. post-login permission/config refresh) can contribute to NG0101.
this.queue.add(() => this.cdRef.detectChanges());
}
} else {
this.cdRef.markForCheck();

2
npm/ng-packs/packages/theme-shared/src/lib/components/breadcrumb/breadcrumb.component.html

@ -1 +1 @@
<abp-breadcrumb-items [items]="segments"></abp-breadcrumb-items>
<abp-breadcrumb-items [items]="segments()" />

13
npm/ng-packs/packages/theme-shared/src/lib/components/breadcrumb/breadcrumb.component.ts

@ -6,7 +6,7 @@ import {
SubscriptionService,
TreeNode,
} from '@abp/ng.core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, inject } from '@angular/core';
import { ChangeDetectionStrategy, Component, OnInit, inject, signal } from '@angular/core';
import { Router } from '@angular/router';
import { map, startWith } from 'rxjs/operators';
import { eThemeSharedRouteNames } from '../../enums/route-names';
@ -20,14 +20,13 @@ import { BreadcrumbItemsComponent } from '../breadcrumb-items/breadcrumb-items.c
imports: [BreadcrumbItemsComponent],
})
export class BreadcrumbComponent implements OnInit {
readonly cdRef = inject(ChangeDetectorRef);
private router = inject(Router);
private routes = inject(RoutesService);
private subscription = inject(SubscriptionService);
private routerEvents = inject(RouterEvents);
private routeCultureUrl = inject(RouteBasedCultureUrlService);
segments: Partial<ABP.Route>[] = [];
readonly segments = signal<Partial<ABP.Route>[]>([]);
ngOnInit(): void {
this.subscription.addOne(
@ -38,18 +37,18 @@ export class BreadcrumbComponent implements OnInit {
),
),
route => {
this.segments = [];
const next: Partial<ABP.Route>[] = [];
if (route) {
let node = { parent: route } as TreeNode<ABP.Route>;
while (node.parent) {
node = node.parent;
const { parent, children, isLeaf, ...segment } = node;
if (!isAdministration(segment)) this.segments.unshift(segment);
if (!isAdministration(segment)) next.unshift(segment);
}
this.cdRef.detectChanges();
}
this.segments.set(next);
},
);
}

6
npm/ng-packs/packages/theme-shared/src/lib/services/toaster.service.ts

@ -1,4 +1,4 @@
import { ApplicationRef, ComponentRef, inject, Injectable } from '@angular/core';
import { ComponentRef, inject, Injectable } from '@angular/core';
import {
ContentProjectionService,
LocalizationParam,
@ -12,7 +12,6 @@ import { Toaster } from '../models';
providedIn: 'root',
})
export class ToasterService implements ToasterContract {
private readonly appRef = inject(ApplicationRef);
private readonly contentProjectionService = inject(ContentProjectionService);
private lastId = -1;
@ -37,8 +36,9 @@ export class ToasterService implements ToasterContract {
}
this.containerComponentRef.instance.setToasts(this.toasts);
// Only refresh the projected toast host. Calling ApplicationRef.tick() here
// races with zone-driven CD and throws NG0101 (recursive tick).
this.containerComponentRef.changeDetectorRef.detectChanges();
this.appRef.tick();
}
/**

2
npm/ng-packs/packages/theme-shared/src/lib/tests/breadcrumb.component.spec.ts

@ -135,7 +135,7 @@ describe('BreadcrumbComponent', () => {
const breadcrumb = spectator.fixture.debugElement.query(By.directive(BreadcrumbComponent))
.componentInstance as BreadcrumbComponent;
expect(breadcrumb.segments.map(segment => segment.path)).toEqual([
expect(breadcrumb.segments().map(segment => segment.path)).toEqual([
'/identity',
'/identity/users',
]);

Loading…
Cancel
Save