Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Close the top most modal by id #30030

Open
3 tasks done
seopei opened this issue Nov 21, 2024 · 0 comments
Open
3 tasks done

feat: Close the top most modal by id #30030

seopei opened this issue Nov 21, 2024 · 0 comments
Labels

Comments

@seopei
Copy link

seopei commented Nov 21, 2024

Prerequisites

Describe the Feature Request

Currently you are able to create multiple modals with an id. eg:

const modal = await this.modalCtrl.create({
  component: ModalExampleComponent,
  id: 'my-id'
});
modal.present();

When I dismiss the modal via this.modalCtrl.dimiss(undefined, undefined, 'my-id') the bottom most modal with this id will be closed. If I do not specify the id the to most modal will be closed. It would be great if always the top most modal would be closed.

Describe the Use Case

I want to present multiple modals with the same id. When I close an modal by id the top most modal with this id should be closed.

Describe Preferred Solution

No response

Describe Alternatives

No response

Related Code

see core/src/utils/overlays.ts

change this

export const getPresentedOverlay = (
  doc: Document,
  overlayTag?: string,
  id?: string
): HTMLIonOverlayElement | undefined => {
  const overlays = getPresentedOverlays(doc, overlayTag);
  return id === undefined ? overlays[overlays.length - 1] : overlays.find((o) => o.id === id);
};

into this

export const getPresentedOverlay = (
  doc: Document,
  overlayTag?: string,
  id?: string
): HTMLIonOverlayElement | undefined => {
  const overlays = getPresentedOverlays(doc, overlayTag);
  return id === undefined ? overlays[overlays.length - 1] : overlays.slice().reverse().find((o) => o.id === id);
};

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant