Skip to content

Commit

Permalink
Reuse getModalDialogAncestor
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmusKjeldgaard committed Nov 19, 2024
1 parent 21cebd0 commit 57c1236
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { firstValueFrom, Subject } from 'rxjs';
import { WindowRef } from '@kirbydesign/designsystem/types';

import { CommonModule } from '@angular/common';
import { getModalDialogAncestor } from '@kirbydesign/designsystem/helpers';
import { ModalConfig, ShowAlertCallback } from '../config/modal-config';
import { COMPONENT_PROPS } from '../config/modal-config.helper';
import { Modal } from '../../modal.interfaces';
Expand Down Expand Up @@ -45,7 +46,7 @@ export class ModalCompactWrapperComponent implements Modal, OnInit {
componentPropsInjector: Injector;

private ionModalElement: HTMLIonModalElement;
private modalElementDialog: HTMLElement;
private ionModalElementDialog: HTMLElement;
private readonly ionModalDidPresent = new Subject<void>();
private readonly ionModalWillDismiss = new Subject<void>();
readonly didPresent = firstValueFrom(this.ionModalDidPresent);
Expand All @@ -60,7 +61,7 @@ export class ModalCompactWrapperComponent implements Modal, OnInit {

ngOnInit(): void {
this.ionModalElement = this.elementRef.nativeElement.closest('ion-modal');
this.modalElementDialog = this.ionModalElement.shadowRoot.querySelector('[role="dialog"]');
this.ionModalElementDialog = getModalDialogAncestor(this.elementRef.nativeElement);

/* If initialized with ariaLabel, we want to set the aria-label attribute immediately.
* Further updates are handled by title setter.
Expand Down Expand Up @@ -94,8 +95,8 @@ export class ModalCompactWrapperComponent implements Modal, OnInit {
}

private setAriaLabelOnModal() {
if (this.modalElementDialog && this.ariaLabel) {
this.modalElementDialog.ariaLabel = this.ariaLabel;
if (this.ionModalElementDialog && this.ariaLabel) {
this.ionModalElementDialog.ariaLabel = this.ariaLabel;
}
}

Expand Down

0 comments on commit 57c1236

Please sign in to comment.