ionic-team / ionic-team/ionic-docs

content: document the correct way to close the parent modal from a child component

Ouverte
#1,626 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
content
Langage dominant
MDX
Étoiles
621
Forks
3.2k
Merge moyen
1 j 2 h
PR mergées (30 j)
86

Description

# Bug Report

**Ionic version:**

[x] **4.5**

**Current behavior:**

`this.modalCtrl.dismiss` closes a modal instance most recently opened, not a parent one ( https://github.com/ionic-team/ionic/tree/v4.5.0/core/src/components/modal#dismissing-a-modal )

and we found the modal instance is [passed in addition to componentProps](https://github.com/ionic-team/ionic/blob/0f242fd956f8cf0143ef36e9cadb1f8dac62cadd/core/src/components/modal/modal.tsx#L154)

It seems that using modal instance passed through `@Input` or `NavParams` is correct way to close the parent modal.

Is this behavior stable?

**Expected behavior:**

If it is, this behavior should be documented.

**Other information:**

[related StackOverflow question](https://stackoverflow.com/questions/52465154/ionic-4-angular-how-to-self-dismiss-a-modal/54969834#54969834)

**Ionic info:**

```
Ionic:

ionic (Ionic CLI) : 4.12.0
Ionic Framework : @ionic/angular 4.4.2
@angular-devkit/build-angular : 0.13.6
@angular-devkit/schematics : 7.3.6
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.4.1

Cordova:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 8.0.0, browser 6.0.0, ios 5.0.1
Cordova Plugins : cordova-plugin-ionic 5.3.0, cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.5.0, (and 22 other plugins)

System:

Android SDK Tools : 26.1.1 (/Users/buko106/Library/Android/sdk)
ios-deploy : 1.9.4
ios-sim : 8.0.1
NodeJS : v10.16.0 (/Users/buko106/.anyenv/envs/nodenv/versions/10.16.0/bin/node)
npm : 6.9.0
OS : macOS Mojave
Xcode : Xcode 10.2.1 Build version 10E1001
```

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.