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: canDismiss handler for modal should accept role #26292

Closed
3 tasks done
sean-perkins opened this issue Nov 15, 2022 · 2 comments
Closed
3 tasks done

feat: canDismiss handler for modal should accept role #26292

sean-perkins opened this issue Nov 15, 2022 · 2 comments
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement

Comments

@sean-perkins
Copy link
Contributor

Prerequisites

Describe the Feature Request

The canDismiss handler for ion-modal should accept an argument for role.

canDismiss(role?: string): boolean;

Describe the Use Case

With swipeToClose being deprecated and removed in the near future, developers will need to migrate their implementation to use canDismiss. canDismiss while similar to the behavior of swipeToClose, behaves differently and can require additional code for developers.

For example, if a user is presenting a card modal, but wants to disable swiping to dismiss the overlay they will need to set canDismiss to false. But when a button is clicked to dismiss the overlay, developers will now need to set canDismiss to true. This requires an additional property in the implementation to keep track of the state of canDismiss. Prior to the deprecation of swipeToClose, developers would just set swipeToClose to false and when dismissing the overlay, the overlay would dismiss without any additional action required by the developer.

Describe Preferred Solution

<ion-modal [canDismiss]="canDismiss"></ion-modal>
canDismiss = (role?: string) => {
  // roles tied to clicking a "Confirm" button or "Cancel" button.
  return role === 'confirm' || role === 'cancel';
}

Describe Alternatives

No response

Related Code

No response

Additional Information

This feature was split from discussion started here: #26173 (comment)

@ionitron-bot ionitron-bot bot added the triage label Nov 15, 2022
@sean-perkins sean-perkins added type: feature request a new feature, enhancement, or improvement package: core @ionic/core package labels Nov 15, 2022
liamdebeasi added a commit that referenced this issue Dec 2, 2022

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
resolves #26292
@liamdebeasi
Copy link
Contributor

Resolved via #26384

@ionitron-bot
Copy link

ionitron-bot bot commented Jan 1, 2023

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Jan 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement
Projects
None yet
Development

No branches or pull requests

2 participants