mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 11:17:19 +08:00
fix(overlay): using hostData for zIndex
This commit is contained in:
@ -146,8 +146,6 @@ export class ActionSheet implements OverlayInterface {
|
|||||||
|
|
||||||
this.ionActionSheetWillPresent.emit();
|
this.ionActionSheetWillPresent.emit();
|
||||||
|
|
||||||
this.el.style.zIndex = `${20000 + this.overlayId}`;
|
|
||||||
|
|
||||||
// get the user's animation fn if one was provided
|
// get the user's animation fn if one was provided
|
||||||
const animationBuilder = this.enterAnimation || this.config.get('actionSheetEnter', this.mode === 'ios' ? iosEnterAnimation : mdEnterAnimation);
|
const animationBuilder = this.enterAnimation || this.config.get('actionSheetEnter', this.mode === 'ios' ? iosEnterAnimation : mdEnterAnimation);
|
||||||
|
|
||||||
@ -198,6 +196,9 @@ export class ActionSheet implements OverlayInterface {
|
|||||||
const themedClasses = this.translucent ? createThemedClasses(this.mode, this.color, 'action-sheet-translucent') : {};
|
const themedClasses = this.translucent ? createThemedClasses(this.mode, this.color, 'action-sheet-translucent') : {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
style: {
|
||||||
|
zIndex: 20000 + this.overlayId,
|
||||||
|
},
|
||||||
class: {
|
class: {
|
||||||
...themedClasses,
|
...themedClasses,
|
||||||
...getClassMap(this.cssClass)
|
...getClassMap(this.cssClass)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Component, Element, Event, EventEmitter, Listen, Method, Prop } from '@stencil/core';
|
import { Component, Element, Event, EventEmitter, Listen, Method, Prop } from '@stencil/core';
|
||||||
import { Animation, AnimationBuilder, Config, CssClassMap, DomController, OverlayDismissEvent, OverlayDismissEventDetail } from '../../index';
|
import { Animation, AnimationBuilder, Config, CssClassMap, DomController, OverlayDismissEvent, OverlayDismissEventDetail } from '../../index';
|
||||||
import { autoFocus, domControllerAsync } from '../../utils/helpers';
|
import { domControllerAsync } from '../../utils/helpers';
|
||||||
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
||||||
import { BACKDROP, OverlayInterface, overlayAnimation } from '../../utils/overlays';
|
import { BACKDROP, OverlayInterface, autoFocus, overlayAnimation } from '../../utils/overlays';
|
||||||
|
|
||||||
import iosEnterAnimation from './animations/ios.enter';
|
import iosEnterAnimation from './animations/ios.enter';
|
||||||
import iosLeaveAnimation from './animations/ios.leave';
|
import iosLeaveAnimation from './animations/ios.leave';
|
||||||
@ -128,10 +128,6 @@ export class Alert implements OverlayInterface {
|
|||||||
this.ionAlertDidLoad.emit();
|
this.ionAlertDidLoad.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidEnter() {
|
|
||||||
this.ionAlertDidPresent.emit();
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUnload() {
|
componentDidUnload() {
|
||||||
this.ionAlertDidUnload.emit();
|
this.ionAlertDidUnload.emit();
|
||||||
}
|
}
|
||||||
@ -152,8 +148,6 @@ export class Alert implements OverlayInterface {
|
|||||||
this.presented = true;
|
this.presented = true;
|
||||||
this.ionAlertWillPresent.emit();
|
this.ionAlertWillPresent.emit();
|
||||||
|
|
||||||
this.el.style.zIndex = `${20000 + this.overlayId}`;
|
|
||||||
|
|
||||||
// get the user's animation fn if one was provided
|
// get the user's animation fn if one was provided
|
||||||
const animationBuilder = this.enterAnimation || this.config.get('alertEnter', this.mode === 'ios' ? iosEnterAnimation : mdEnterAnimation);
|
const animationBuilder = this.enterAnimation || this.config.get('alertEnter', this.mode === 'ios' ? iosEnterAnimation : mdEnterAnimation);
|
||||||
|
|
||||||
@ -337,6 +331,9 @@ export class Alert implements OverlayInterface {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
role: 'alertdialog',
|
role: 'alertdialog',
|
||||||
|
style: {
|
||||||
|
zIndex: 20000 + this.overlayId,
|
||||||
|
},
|
||||||
class: {
|
class: {
|
||||||
...themedClasses,
|
...themedClasses,
|
||||||
...getClassMap(this.cssClass)
|
...getClassMap(this.cssClass)
|
||||||
|
@ -158,8 +158,6 @@ export class Loading implements OverlayInterface {
|
|||||||
this.presented = true;
|
this.presented = true;
|
||||||
this.ionLoadingWillPresent.emit();
|
this.ionLoadingWillPresent.emit();
|
||||||
|
|
||||||
this.el.style.zIndex = `${20000 + this.overlayId}`;
|
|
||||||
|
|
||||||
// get the user's animation fn if one was provided
|
// get the user's animation fn if one was provided
|
||||||
const animationBuilder = this.enterAnimation || this.config.get('loadingEnter', this.mode === 'ios' ? iosEnterAnimation : mdEnterAnimation);
|
const animationBuilder = this.enterAnimation || this.config.get('loadingEnter', this.mode === 'ios' ? iosEnterAnimation : mdEnterAnimation);
|
||||||
|
|
||||||
@ -208,6 +206,9 @@ export class Loading implements OverlayInterface {
|
|||||||
const themedClasses = this.translucent ? createThemedClasses(this.mode, this.color, 'loading-translucent') : {};
|
const themedClasses = this.translucent ? createThemedClasses(this.mode, this.color, 'loading-translucent') : {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
style: {
|
||||||
|
zIndex: 20000 + this.overlayId,
|
||||||
|
},
|
||||||
class: {
|
class: {
|
||||||
...themedClasses,
|
...themedClasses,
|
||||||
...getClassMap(this.cssClass)
|
...getClassMap(this.cssClass)
|
||||||
|
@ -237,8 +237,10 @@ export class Menu {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
// Destroy existing animation
|
// Destroy existing animation
|
||||||
this.animation && this.animation.destroy();
|
if (this.animation) {
|
||||||
this.animation = null;
|
this.animation.destroy();
|
||||||
|
this.animation = null;
|
||||||
|
}
|
||||||
this.width = width;
|
this.width = width;
|
||||||
|
|
||||||
// Create new animation
|
// Create new animation
|
||||||
|
@ -155,8 +155,6 @@ export class Modal implements OverlayInterface {
|
|||||||
this.presented = true;
|
this.presented = true;
|
||||||
this.ionModalWillPresent.emit();
|
this.ionModalWillPresent.emit();
|
||||||
|
|
||||||
this.el.style.zIndex = `${20000 + this.overlayId}`;
|
|
||||||
|
|
||||||
// get the user's animation fn if one was provided
|
// get the user's animation fn if one was provided
|
||||||
const animationBuilder = this.enterAnimation || this.config.get('modalEnter', this.mode === 'ios' ? iosEnterAnimation : mdEnterAnimation);
|
const animationBuilder = this.enterAnimation || this.config.get('modalEnter', this.mode === 'ios' ? iosEnterAnimation : mdEnterAnimation);
|
||||||
|
|
||||||
@ -222,6 +220,14 @@ export class Modal implements OverlayInterface {
|
|||||||
return this.el.querySelector(`.${USER_COMPONENT_MODAL_CONTAINER_CLASS}`);
|
return this.el.querySelector(`.${USER_COMPONENT_MODAL_CONTAINER_CLASS}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hostData() {
|
||||||
|
return {
|
||||||
|
style: {
|
||||||
|
zIndex: 20000 + this.overlayId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const dialogClasses = createThemedClasses(this.mode, this.color, 'modal-wrapper');
|
const dialogClasses = createThemedClasses(this.mode, this.color, 'modal-wrapper');
|
||||||
|
|
||||||
|
@ -163,15 +163,8 @@ export class Picker implements OverlayInterface {
|
|||||||
}
|
}
|
||||||
this.presented = true;
|
this.presented = true;
|
||||||
|
|
||||||
if (this.animation) {
|
|
||||||
this.animation.destroy();
|
|
||||||
this.animation = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ionPickerWillPresent.emit();
|
this.ionPickerWillPresent.emit();
|
||||||
|
|
||||||
this.el.style.zIndex = `${20000 + this.overlayId}`;
|
|
||||||
|
|
||||||
// get the user's animation fn if one was provided
|
// get the user's animation fn if one was provided
|
||||||
const animationBuilder = this.enterAnimation || this.config.get('pickerEnter', iosEnterAnimation);
|
const animationBuilder = this.enterAnimation || this.config.get('pickerEnter', iosEnterAnimation);
|
||||||
|
|
||||||
@ -271,6 +264,14 @@ export class Picker implements OverlayInterface {
|
|||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hostData() {
|
||||||
|
return {
|
||||||
|
style: {
|
||||||
|
zIndex: 20000 + this.overlayId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
// TODO: cssClass
|
// TODO: cssClass
|
||||||
|
|
||||||
|
@ -131,6 +131,12 @@ export class Popover implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Event() ionPopoverDidUnload: EventEmitter<PopoverEventDetail>;
|
@Event() ionPopoverDidUnload: EventEmitter<PopoverEventDetail>;
|
||||||
|
|
||||||
|
componentWillLoad() {
|
||||||
|
if (!this.delegate) {
|
||||||
|
this.delegate = new DomFrameworkDelegate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentDidLoad() {
|
componentDidLoad() {
|
||||||
this.ionPopoverDidLoad.emit();
|
this.ionPopoverDidLoad.emit();
|
||||||
}
|
}
|
||||||
@ -164,15 +170,10 @@ export class Popover implements OverlayInterface {
|
|||||||
|
|
||||||
this.ionPopoverWillPresent.emit();
|
this.ionPopoverWillPresent.emit();
|
||||||
|
|
||||||
this.el.style.zIndex = `${10000 + this.overlayId}`;
|
|
||||||
|
|
||||||
// get the user's animation fn if one was provided
|
// get the user's animation fn if one was provided
|
||||||
const animationBuilder = this.enterAnimation || this.config.get('popoverEnter', this.mode === 'ios' ? iosEnterAnimation : mdEnterAnimation);
|
const animationBuilder = this.enterAnimation || this.config.get('popoverEnter', this.mode === 'ios' ? iosEnterAnimation : mdEnterAnimation);
|
||||||
|
|
||||||
const userComponentParent = this.el.querySelector(`.${USER_COMPONENT_POPOVER_CONTAINER_CLASS}`);
|
const userComponentParent = this.el.querySelector(`.${USER_COMPONENT_POPOVER_CONTAINER_CLASS}`);
|
||||||
if (!this.delegate) {
|
|
||||||
this.delegate = new DomFrameworkDelegate();
|
|
||||||
}
|
|
||||||
|
|
||||||
const cssClasses: string[] = [];
|
const cssClasses: string[] = [];
|
||||||
if (this.cssClass && this.cssClass.length) {
|
if (this.cssClass && this.cssClass.length) {
|
||||||
@ -203,17 +204,9 @@ export class Popover implements OverlayInterface {
|
|||||||
return Promise.reject('overlay is not presented');
|
return Promise.reject('overlay is not presented');
|
||||||
}
|
}
|
||||||
this.presented = false;
|
this.presented = false;
|
||||||
if (this.animation) {
|
|
||||||
this.animation.destroy();
|
|
||||||
this.animation = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ionPopoverWillDismiss.emit({ data, role });
|
this.ionPopoverWillDismiss.emit({ data, role });
|
||||||
|
|
||||||
if (!this.delegate) {
|
|
||||||
this.delegate = new DomFrameworkDelegate();
|
|
||||||
}
|
|
||||||
|
|
||||||
const animationBuilder = this.leaveAnimation || this.config.get('popoverLeave', this.mode === 'ios' ? iosLeaveAnimation : mdLeaveAnimation);
|
const animationBuilder = this.leaveAnimation || this.config.get('popoverLeave', this.mode === 'ios' ? iosLeaveAnimation : mdLeaveAnimation);
|
||||||
|
|
||||||
return this.playAnimation(animationBuilder).then(() => {
|
return this.playAnimation(animationBuilder).then(() => {
|
||||||
@ -235,6 +228,9 @@ export class Popover implements OverlayInterface {
|
|||||||
const themedClasses = this.translucent ? createThemedClasses(this.mode, this.color, 'popover-translucent') : {};
|
const themedClasses = this.translucent ? createThemedClasses(this.mode, this.color, 'popover-translucent') : {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
style: {
|
||||||
|
zIndex: 10000 + this.overlayId,
|
||||||
|
},
|
||||||
class: {
|
class: {
|
||||||
...themedClasses
|
...themedClasses
|
||||||
}
|
}
|
||||||
|
@ -15,16 +15,6 @@ export function assert(actual: any, reason: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function autoFocus(containerEl: HTMLElement): HTMLElement|null {
|
|
||||||
const focusableEls = containerEl.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]');
|
|
||||||
if (focusableEls.length > 0) {
|
|
||||||
const el = focusableEls[0] as HTMLInputElement;
|
|
||||||
el.focus();
|
|
||||||
return el;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function now(ev: UIEvent) {
|
export function now(ev: UIEvent) {
|
||||||
return ev.timeStamp || Date.now();
|
return ev.timeStamp || Date.now();
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,16 @@ export function overlayAnimation(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function autoFocus(containerEl: HTMLElement): HTMLElement {
|
||||||
|
const focusableEls = containerEl.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]');
|
||||||
|
if (focusableEls.length > 0) {
|
||||||
|
const el = focusableEls[0] as HTMLInputElement;
|
||||||
|
el.focus();
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
export interface OverlayInterface {
|
export interface OverlayInterface {
|
||||||
overlayId: number;
|
overlayId: number;
|
||||||
animation: Animation|undefined;
|
animation: Animation|undefined;
|
||||||
|
Reference in New Issue
Block a user