From ded6445f36095db6b722781fe4e698304a850b04 Mon Sep 17 00:00:00 2001 From: Diego Franchina Date: Sun, 3 Dec 2023 18:15:10 +0100 Subject: [PATCH 1/2] Add detectChanges() onInit --- .../components/autocomplete/autocomplete.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/app/components/autocomplete/autocomplete.ts b/src/app/components/autocomplete/autocomplete.ts index 7ce3ba92bee..78cd9686a75 100755 --- a/src/app/components/autocomplete/autocomplete.ts +++ b/src/app/components/autocomplete/autocomplete.ts @@ -718,9 +718,9 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr _suggestions = signal(null); - onModelChange: Function = () => {}; + onModelChange: Function = () => { }; - onModelTouched: Function = () => {}; + onModelTouched: Function = () => { }; timeout: Nullable; @@ -844,10 +844,11 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr return !this.virtualScroll; } - constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public config: PrimeNGConfig, public overlayService: OverlayService, private zone: NgZone) {} + constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public config: PrimeNGConfig, public overlayService: OverlayService, private zone: NgZone) { } ngOnInit() { this.id = this.id || UniqueComponentId(); + this.cd.detectChanges() } ngAfterViewChecked() { @@ -973,8 +974,8 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr const matchedOptionIndex = index < this.visibleOptions().length - 1 ? this.visibleOptions() - .slice(index + 1) - .findIndex((option) => this.isValidOption(option)) + .slice(index + 1) + .findIndex((option) => this.isValidOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index; @@ -1528,9 +1529,9 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr return ( (this.optionGroupLabel ? index - - this.visibleOptions() - .slice(0, index) - .filter((option) => this.isOptionGroup(option)).length + this.visibleOptions() + .slice(0, index) + .filter((option) => this.isOptionGroup(option)).length : index) + 1 ); } @@ -1607,4 +1608,4 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr exports: [AutoComplete, OverlayModule, SharedModule, ScrollerModule, AutoFocusModule], declarations: [AutoComplete] }) -export class AutoCompleteModule {} +export class AutoCompleteModule { } From 960482bcf3e7bcba85fb3d2bf9550fe98487cde1 Mon Sep 17 00:00:00 2001 From: Diego Franchina Date: Sun, 3 Dec 2023 18:15:42 +0100 Subject: [PATCH 2/2] Formatted code --- .../components/autocomplete/autocomplete.ts | 20 +++++++++---------- src/app/components/image/image.ts | 2 +- src/app/components/toast/toast.ts | 4 +--- .../showcase/doc/Image/accessibilitydoc.ts | 4 +--- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/app/components/autocomplete/autocomplete.ts b/src/app/components/autocomplete/autocomplete.ts index 78cd9686a75..dde193169dd 100755 --- a/src/app/components/autocomplete/autocomplete.ts +++ b/src/app/components/autocomplete/autocomplete.ts @@ -718,9 +718,9 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr _suggestions = signal(null); - onModelChange: Function = () => { }; + onModelChange: Function = () => {}; - onModelTouched: Function = () => { }; + onModelTouched: Function = () => {}; timeout: Nullable; @@ -844,11 +844,11 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr return !this.virtualScroll; } - constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public config: PrimeNGConfig, public overlayService: OverlayService, private zone: NgZone) { } + constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public config: PrimeNGConfig, public overlayService: OverlayService, private zone: NgZone) {} ngOnInit() { this.id = this.id || UniqueComponentId(); - this.cd.detectChanges() + this.cd.detectChanges(); } ngAfterViewChecked() { @@ -974,8 +974,8 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr const matchedOptionIndex = index < this.visibleOptions().length - 1 ? this.visibleOptions() - .slice(index + 1) - .findIndex((option) => this.isValidOption(option)) + .slice(index + 1) + .findIndex((option) => this.isValidOption(option)) : -1; return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index; @@ -1529,9 +1529,9 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr return ( (this.optionGroupLabel ? index - - this.visibleOptions() - .slice(0, index) - .filter((option) => this.isOptionGroup(option)).length + this.visibleOptions() + .slice(0, index) + .filter((option) => this.isOptionGroup(option)).length : index) + 1 ); } @@ -1608,4 +1608,4 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr exports: [AutoComplete, OverlayModule, SharedModule, ScrollerModule, AutoFocusModule], declarations: [AutoComplete] }) -export class AutoCompleteModule { } +export class AutoCompleteModule {} diff --git a/src/app/components/image/image.ts b/src/app/components/image/image.ts index 8114ef6fc2f..3b30f54ba52 100755 --- a/src/app/components/image/image.ts +++ b/src/app/components/image/image.ts @@ -376,7 +376,7 @@ export class Image implements AfterContentInit { imagePreviewStyle() { return { transform: 'rotate(' + this.rotate + 'deg) scale(' + this.scale + ')' }; } - + get zoomImageAriaLabel() { return this.config.translation.aria ? this.config.translation.aria.zoomImage : undefined; } diff --git a/src/app/components/toast/toast.ts b/src/app/components/toast/toast.ts index 7cc2dc1d57d..5843c4d82ab 100755 --- a/src/app/components/toast/toast.ts +++ b/src/app/components/toast/toast.ts @@ -140,7 +140,7 @@ export class ToastItem implements AfterViewInit, OnDestroy { timeout: any; - constructor(private zone: NgZone,private config: PrimeNGConfig) {} + constructor(private zone: NgZone, private config: PrimeNGConfig) {} ngAfterViewInit() { this.initTimeout(); @@ -192,8 +192,6 @@ export class ToastItem implements AfterViewInit, OnDestroy { ngOnDestroy() { this.clearTimeout(); } - - } /** diff --git a/src/app/showcase/doc/Image/accessibilitydoc.ts b/src/app/showcase/doc/Image/accessibilitydoc.ts index 4b18d77a9a1..729f8871be9 100644 --- a/src/app/showcase/doc/Image/accessibilitydoc.ts +++ b/src/app/showcase/doc/Image/accessibilitydoc.ts @@ -4,9 +4,7 @@ import { Component } from '@angular/core'; selector: 'accessibility-doc', template: `

Screen Reader

-

- The preview button is a native button element with an aria-label that refers to the aria.zoomImage property of the locale API by default. -

+

The preview button is a native button element with an aria-label that refers to the aria.zoomImage property of the locale API by default.

When preview is active, dialog role with aria-modal is applied to the overlay image container.

Button controls use aria.rotateRight, aria.rotateLeft, aria.zoomIn, aria.zoomOut and aria.close from the locale API as aria-label.

ButtonBar Keyboard Support