/
githubmirror
/
ionic
Обзор
Документация
Войти
/
githubmirror
/
ionic
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
core/src/components/backdrop/backdrop.tsx
63 строки
1 KB
Maria Hutt
fix(backdrop): remove tabindex for improved accessibility (#29956)
22 окт 2024, 18:07
Не верифицирован
22 окт 2024, 18:07
7294e96
Код
Авторство
О чём код?
import type { ComponentInterface, EventEmitter } from '@stencil/core'; import { Component, Event, Host, Listen, Prop, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; @Component({ tag: 'ion-backdrop', styleUrls: { ios: 'backdrop.ios.scss', md: 'backdrop.md.scss', }, shadow: true, }) export class Backdrop implements ComponentInterface { /** * If `true`, the backdrop will be visible. */ @Prop() visible = true; /** * If `true`, the backdrop will can be clicked and will emit the `ionBackdropTap` event. */ @Prop() tappable = true; /** * If `true`, the backdrop will stop propagation on tap. */ @Prop() stopPropagation = true; /** * Emitted when the backdrop is tapped. */ @Event() ionBackdropTap!: EventEmitter<void>; @Listen('click', { passive: false, capture: true }) protected onMouseDown(ev: TouchEvent) { this.emitTap(ev); } private emitTap(ev: Event) { if (this.stopPropagation) { ev.preventDefault(); ev.stopPropagation(); } if (this.tappable) { this.ionBackdropTap.emit(); } } render() { const mode = getIonMode(this); return ( <Host aria-hidden="true" class={{ [mode]: true, 'backdrop-hide': !this.visible, 'backdrop-no-tappable': !this.tappable, }} ></Host> ); } }