()
| 813 | } |
| 814 | |
| 815 | render() { |
| 816 | const { overlayIndex, header, subHeader, message, htmlAttributes } = this; |
| 817 | const mode = getIonMode(this); |
| 818 | const hdrId = `alert-${overlayIndex}-hdr`; |
| 819 | const msgId = `alert-${overlayIndex}-msg`; |
| 820 | const subHdrId = `alert-${overlayIndex}-sub-hdr`; |
| 821 | const role = this.inputs.length > 0 || this.buttons.length > 0 ? 'alertdialog' : 'alert'; |
| 822 | |
| 823 | /** |
| 824 | * Use both the header and subHeader ids if they are defined. |
| 825 | * If only the header is defined, use the header id. |
| 826 | * If only the subHeader is defined, use the subHeader id. |
| 827 | * If neither are defined, do not set aria-labelledby. |
| 828 | */ |
| 829 | const ariaLabelledBy = header && subHeader ? `${hdrId} ${subHdrId}` : header ? hdrId : subHeader ? subHdrId : null; |
| 830 | |
| 831 | return ( |
| 832 | <Host |
| 833 | tabindex="-1" |
| 834 | style={{ |
| 835 | zIndex: `${20000 + overlayIndex}`, |
| 836 | }} |
| 837 | class={{ |
| 838 | ...getClassMap(this.cssClass), |
| 839 | [mode]: true, |
| 840 | 'overlay-hidden': true, |
| 841 | 'alert-translucent': this.translucent, |
| 842 | }} |
| 843 | onIonAlertWillDismiss={this.dispatchCancelHandler} |
| 844 | onIonBackdropTap={this.onBackdropTap} |
| 845 | > |
| 846 | <ion-backdrop tappable={this.backdropDismiss} /> |
| 847 | |
| 848 | <div tabindex="0" aria-hidden="true"></div> |
| 849 | |
| 850 | <div |
| 851 | class="alert-wrapper ion-overlay-wrapper" |
| 852 | role={role} |
| 853 | aria-modal="true" |
| 854 | aria-labelledby={ariaLabelledBy} |
| 855 | aria-describedby={message !== undefined ? msgId : null} |
| 856 | tabindex="0" |
| 857 | ref={(el) => (this.wrapperEl = el)} |
| 858 | {...(htmlAttributes as any)} |
| 859 | > |
| 860 | <div class="alert-head"> |
| 861 | {header && ( |
| 862 | <h2 id={hdrId} class="alert-title"> |
| 863 | {header} |
| 864 | </h2> |
| 865 | )} |
| 866 | {/* If no header exists, subHeader should be the highest heading level, h2 */} |
| 867 | {subHeader && !header && ( |
| 868 | <h2 id={subHdrId} class="alert-sub-title"> |
| 869 | {subHeader} |
| 870 | </h2> |
| 871 | )} |
| 872 | {/* If a header exists, subHeader should be one level below it, h3 */} |
nothing calls this directly
no test coverage detected