Skip to content

Commit

Permalink
Fixed #15155 - Component: Dropdown Accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetcetin01140 committed Jul 8, 2024
1 parent 9fa4ccd commit e0edd92
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 17 deletions.
10 changes: 9 additions & 1 deletion src/app/components/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,15 @@ export class Calendar implements OnInit, OnDestroy, ControlValueAccessor {
return this.currentView === 'year' ? this.getTranslation('nextDecade') : this.currentView === 'month' ? this.getTranslation('nextYear') : this.getTranslation('nextMonth');
}

constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, private zone: NgZone, private config: PrimeNGConfig, public overlayService: OverlayService) {
constructor(
@Inject(DOCUMENT) private document: Document,
public el: ElementRef,
public renderer: Renderer2,
public cd: ChangeDetectorRef,
private zone: NgZone,
private config: PrimeNGConfig,
public overlayService: OverlayService
) {
this.window = this.document.defaultView as Window;
}

Expand Down
10 changes: 9 additions & 1 deletion src/app/components/carousel/carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,15 @@ export class Carousel implements AfterContentInit {

window: Window;

constructor(public el: ElementRef, public zone: NgZone, public cd: ChangeDetectorRef, private renderer: Renderer2, @Inject(DOCUMENT) private document: Document, @Inject(PLATFORM_ID) private platformId: any, private config: PrimeNGConfig) {
constructor(
public el: ElementRef,
public zone: NgZone,
public cd: ChangeDetectorRef,
private renderer: Renderer2,
@Inject(DOCUMENT) private document: Document,
@Inject(PLATFORM_ID) private platformId: any,
private config: PrimeNGConfig
) {
this.totalShiftedItems = this.page * this.numScroll * -1;
this.window = this.document.defaultView as Window;
}
Expand Down
10 changes: 9 additions & 1 deletion src/app/components/confirmdialog/confirmdialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,15 @@ export class ConfirmDialog implements AfterContentInit, OnInit, OnDestroy {

translationSubscription: Subscription | undefined;

constructor(public el: ElementRef, public renderer: Renderer2, private confirmationService: ConfirmationService, public zone: NgZone, private cd: ChangeDetectorRef, public config: PrimeNGConfig, @Inject(DOCUMENT) private document: Document) {
constructor(
public el: ElementRef,
public renderer: Renderer2,
private confirmationService: ConfirmationService,
public zone: NgZone,
private cd: ChangeDetectorRef,
public config: PrimeNGConfig,
@Inject(DOCUMENT) private document: Document
) {
this.subscription = this.confirmationService.requireConfirmation$.subscribe((confirmation) => {
if (!confirmation) {
this.hide();
Expand Down
10 changes: 9 additions & 1 deletion src/app/components/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,15 @@ export class Dialog implements AfterContentInit, OnInit, OnDestroy {
return this.config.getTranslation(TranslationKeys.ARIA)['maximizeLabel'];
}

constructor(@Inject(DOCUMENT) private document: Document, @Inject(PLATFORM_ID) private platformId: any, public el: ElementRef, public renderer: Renderer2, public zone: NgZone, private cd: ChangeDetectorRef, public config: PrimeNGConfig) {
constructor(
@Inject(DOCUMENT) private document: Document,
@Inject(PLATFORM_ID) private platformId: any,
public el: ElementRef,
public renderer: Renderer2,
public zone: NgZone,
private cd: ChangeDetectorRef,
public config: PrimeNGConfig
) {
this.window = this.document.defaultView as Window;
}

Expand Down
15 changes: 10 additions & 5 deletions src/app/components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ export class DropdownItem {
</div>
</ng-template>
</div>
<div class="p-dropdown-items-wrapper" [style.max-height]="virtualScroll ? 'auto' : scrollHeight || 'auto'">
<span role="presentation" class="p-hidden-accessible p-hidden-focusable" [attr.tabindex]="0" [attr.data-p-hidden-accessible]="true" [attr.data-p-hidden-focusable]="true"></span>
<div class="p-dropdown-items-wrapper" [style.max-height]="virtualScroll ? 'auto' : scrollHeight || 'auto'" tabindex="0">
<p-scroller
*ngIf="virtualScroll"
#scroller
Expand Down Expand Up @@ -1014,7 +1012,14 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV

editableInputValue = computed(() => this.getOptionLabel(this.selectedOption) || this.modelValue() || '');

constructor(public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public zone: NgZone, public filterService: FilterService, public config: PrimeNGConfig) {
constructor(
public el: ElementRef,
public renderer: Renderer2,
public cd: ChangeDetectorRef,
public zone: NgZone,
public filterService: FilterService,
public config: PrimeNGConfig
) {
effect(() => {
const modelValue = this.modelValue();
const visibleOptions = this.visibleOptions();
Expand Down Expand Up @@ -1825,7 +1830,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
}

hasFocusableElements() {
return DomHandler.getFocusableElements(this.overlayViewChild.overlayViewChild.nativeElement, ':not([data-p-hidden-focusable="true"])').length > 0;
return DomHandler.getFocusableElements(this.overlayViewChild.overlayViewChild.nativeElement, ':not([data-p-hidden-focusable="true"]):not([class="p-dropdown-items-wrapper"])').length > 0;
}

onBackspaceKey(event: KeyboardEvent, pressedInInputText = false) {
Expand Down
28 changes: 20 additions & 8 deletions src/app/components/toast/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ 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();
Expand All @@ -159,12 +162,15 @@ export class ToastItem implements AfterViewInit, OnDestroy {
initTimeout() {
if (!this.message?.sticky) {
this.zone.runOutsideAngular(() => {
this.timeout = setTimeout(() => {
this.onClose.emit({
index: <number>this.index,
message: <Message>this.message
});
}, this.message?.life || this.life || 3000);
this.timeout = setTimeout(
() => {
this.onClose.emit({
index: <number>this.index,
message: <Message>this.message
});
},
this.message?.life || this.life || 3000
);
});
}
}
Expand Down Expand Up @@ -343,7 +349,13 @@ export class Toast implements OnInit, AfterContentInit, OnDestroy {

_position: ToastPositionType = 'top-right';

constructor(@Inject(DOCUMENT) private document: Document, private renderer: Renderer2, public messageService: MessageService, private cd: ChangeDetectorRef, public config: PrimeNGConfig) {}
constructor(
@Inject(DOCUMENT) private document: Document,
private renderer: Renderer2,
public messageService: MessageService,
private cd: ChangeDetectorRef,
public config: PrimeNGConfig
) {}

styleElement: any;

Expand Down

0 comments on commit e0edd92

Please sign in to comment.