Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/primefaces/primeng
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed May 14, 2024
2 parents 3038793 + 414793d commit 4154d61
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 18 deletions.
6 changes: 1 addition & 5 deletions src/app/components/dialog/dialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,7 @@ describe('Dialog', () => {
fixture.detectChanges();

tick(300);
const escapeEvent: any = document.createEvent('CustomEvent');
escapeEvent.which = 27;
escapeEvent.initEvent('keydown', true, true);
document.dispatchEvent(escapeEvent);
document.dispatchEvent(escapeEvent as KeyboardEvent);
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
fixture.detectChanges();

expect(closeSpy).toHaveBeenCalled();
Expand Down
15 changes: 11 additions & 4 deletions src/app/components/rating/rating.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ describe('Rating', () => {
fixture.detectChanges();

const starElements = fixture.debugElement.queryAll(By.css('span'));
expect(starElements[0].nativeElement.className).toContain('Primeng Rocks!');
expect(starElements[0].nativeElement.style.height).toEqual('300px');
expect(starElements[1].nativeElement.className).toContain('Primeng Rocks!');
expect(starElements[1].nativeElement.style.height).toEqual('300px');
});

it('should value 3', () => {
Expand All @@ -86,11 +86,18 @@ describe('Rating', () => {
rating.onRate.subscribe((value) => (onRateValue = value));
rating.onCancel.subscribe((value) => (onCancelRate = value));
thirdStarEl.parentElement.click();
cancelEl.parentElement.click();
fixture.detectChanges();

expect(onRateValue.value).toEqual(3);
expect(onCancelRate).toBeTruthy();

const cancelspy = spyOn(rating.onCancel, 'emit').and.callThrough();
const onModelChangeSpy = spyOn(rating, 'onModelChange').and.callThrough();
cancelEl.parentElement.click();
fixture.detectChanges();

expect(onModelChangeSpy).toHaveBeenCalled();
expect(rating.value).toEqual(null);
expect(cancelspy).toHaveBeenCalled();
});

it('should clear value', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,10 @@ export class Tree implements OnInit, AfterContentInit, OnChanges, OnDestroy, Blo
return;
} else if (this.selectionMode) {
if (node.selectable === false) {
node.style = '--p-focus-ring-color: none;';
return;
} else {
node.style = '--p-focus-ring-color: var(--primary-color)';
}

if (this.hasFilteredNodes()) {
Expand Down
39 changes: 30 additions & 9 deletions src/app/showcase/doc/menubar/routerdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,25 @@ import { Router } from '@angular/router';
<div class="card">
<p-menubar [model]="items">
<ng-template pTemplate="item" let-item>
<ng-container *ngIf="item.route; else elseBlock">
<ng-container *ngIf="item.route; else urlRef">
<a [routerLink]="item.route" class="p-menuitem-link">
<span [class]="item.icon"></span>
<span class="ml-2">{{ item.label }}</span>
</a>
</ng-container>
<ng-template #elseBlock>
<a [href]="item.url" class="p-menuitem-link">
<ng-template #urlRef>
<a *ngIf="item.url; else noLink" [href]="item.url" class="p-menuitem-link">
<span [class]="item.icon"></span>
<span class="ml-2">{{ item.label }}</span>
</a>
</ng-template>
<ng-template #noLink>
<div class="p-menuitem-link">
<span [class]="item.icon"></span>
<span class="ml-2">{{ item.label }}</span>
<span class="pi pi-fw pi-angle-down ml-2"></span>
</div>
</ng-template>
</ng-template>
</p-menubar>
</div>
Expand Down Expand Up @@ -78,36 +85,50 @@ export class RouterDoc implements OnInit {
code: Code = {
basic: `<p-menubar [model]="items">
<ng-template pTemplate="item" let-item>
<ng-container *ngIf="item.route; else elseBlock">
<ng-container *ngIf="item.route; else urlRef">
<a [routerLink]="item.route" class="p-menuitem-link">
<span [class]="item.icon"></span>
<span class="ml-2">{{ item.label }}</span>
</a>
</ng-container>
<ng-template #elseBlock>
<a [href]="item.url" class="p-menuitem-link">
<ng-template #urlRef>
<a *ngIf="item.url; else noLink" [href]="item.url" class="p-menuitem-link">
<span [class]="item.icon"></span>
<span class="ml-2">{{ item.label }}</span>
</a>
</ng-template>
<ng-template #noLink>
<div class="p-menuitem-link">
<span [class]="item.icon"></span>
<span class="ml-2">{{ item.label }}</span>
<span class="pi pi-fw pi-angle-down ml-2"></span>
</div>
</ng-template>
</ng-template>
</p-menubar>`,

html: `<div class="card">
<p-menubar [model]="items">
<ng-template pTemplate="item" let-item>
<ng-container *ngIf="item.route; else elseBlock">
<ng-container *ngIf="item.route; else urlRef">
<a [routerLink]="item.route" class="p-menuitem-link">
<span [class]="item.icon"></span>
<span class="ml-2">{{ item.label }}</span>
</a>
</ng-container>
<ng-template #elseBlock>
<a [href]="item.url" class="p-menuitem-link">
<ng-template #urlRef>
<a *ngIf="item.url; else noLink" [href]="item.url" class="p-menuitem-link">
<span [class]="item.icon"></span>
<span class="ml-2">{{ item.label }}</span>
</a>
</ng-template>
<ng-template #noLink>
<div class="p-menuitem-link">
<span [class]="item.icon"></span>
<span class="ml-2">{{ item.label }}</span>
<span class="pi pi-fw pi-angle-down ml-2"></span>
</div>
</ng-template>
</ng-template>
</p-menubar>
</div>`,
Expand Down

0 comments on commit 4154d61

Please sign in to comment.