fix(vue): do not hide page content when using ion-page in non-routing contexts (#22302)

resolves #22300
This commit is contained in:
Liam DeBeasi
2020-10-13 10:29:37 -04:00
committed by GitHub
parent 6026c65b1a
commit fff82d0bdc
3 changed files with 22 additions and 14 deletions

View File

@ -2,12 +2,16 @@ import { h, defineComponent } from 'vue';
export const IonPage = defineComponent({
name: 'IonPage',
setup(_, { attrs, slots }) {
props: {
isInOutlet: { type: Boolean, default: false }
},
setup(props, { attrs, slots }) {
return () => {
const hidePageClass = (props.isInOutlet) ? 'ion-page-invisible' : '';
return h(
'div',
{
['class']: 'ion-page ion-page-invisible',
['class']: `ion-page ${hidePageClass}`,
...attrs,
ref: 'ionPage'
},

View File

@ -301,7 +301,7 @@ export const IonRouterOutlet = defineComponent({
'ion-router-outlet',
{ ref: 'ionRouterOutlet' },
// TODO types
components && components.map((c: any) => h(c.vueComponent, { key: c.pathname }))
components && components.map((c: any) => h(c.vueComponent, { key: c.pathname, isInOutlet: true }))
)
}
});

View File

@ -1,19 +1,22 @@
<template>
<ion-header>
<ion-toolbar>
<ion-buttons>
<ion-button @click="dismiss">Dismiss</ion-button>
</ion-buttons>
<ion-title>Modal</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
{{ title }}
</ion-content>
<ion-page>
<ion-header>
<ion-toolbar>
<ion-buttons>
<ion-button @click="dismiss">Dismiss</ion-button>
</ion-buttons>
<ion-title>Modal</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
{{ title }}
</ion-content>
</ion-page>
</template>
<script lang="ts">
import {
IonPage,
IonButton,
IonButtons,
IonContent,
@ -30,6 +33,7 @@ export default defineComponent({
title: { type: String, default: 'Default Title' }
},
components: {
IonPage,
IonButton,
IonButtons,
IonContent,