infor-design / enterprise

Enterprise-grade component library for the Infor Design System
https://design.infor.com
Apache License 2.0
130 stars 80 forks source link

Modal: Support asynchronous operation in modal.beforeClose() callback #8779

Open InforOttoLing opened 1 month ago

InforOttoLing commented 1 month ago

Is your feature request related to a problem or use case? Please describe. The Modal Component's beforeClose() callback only accepts a callback method that returns boolean. That means, no async operations can be performed within the callback. This prevents user from being able to perform async validation inside the .beforeClose() callback, when deciding whether the modal should be closed or not. For example, if we want to submit a form from a modal, and the API call returns error, we keep the modal opened and display an error message.

Describe the solution you'd like The Modal component would work better if the .beforeClose() can also accept a callback that returns a Promise, so that when .close() is called on the modal, the beforeClose() callback can be executed asynchronously.

Describe alternatives you've considered Instead of using .beforeClose() to decide whether a modal should be closed, we hardcode the validation process into the onClick method in the button that closes the modal, and only invokes modal.close() if validation passes.

Additional context And what application do you work on? Infor Workforce Management(WFM)

tmcconechy commented 1 month ago

@InforOttoLing just a note that the Web Components provide async here. Not sure why we cant it here as well.