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

fix(modal): changing the open property no longer calls beforeClose #7042

Closed
wants to merge 22 commits into from

Conversation

driskull
Copy link
Member

@driskull driskull commented May 26, 2023

Related Issue: #6407 #6379

Summary

  • Changing the property open will no longer call beforeClose.
    • Its up to the developer to call beforeClose when modifying the property.
    • This ensures that the classes added by modal will always be cleaned up.
  • User interaction such as clicking the close button will call beforeClose
  • Cleanup

…6407

introduces a close public method which will call beforeClose
@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label May 26, 2023
@driskull
Copy link
Member Author

driskull commented Jun 2, 2023

@jcfranco I heard back from Stencil regarding validation in the watcher. Here is their response:

Using a watcher to validate and potentially revert property changes based on certain conditions is a valid approach in Ionic apps. The code snippet you provided demonstrates the usage of a watcher to observe changes to the myProperty and perform validation logic.

Based on the information you have provided the approach you described using a watcher to validate and potentially revert property changes is acceptable and aligns with the purpose of watchers in Ionic apps.
Thank you for using ionic,

So we can revert changes in the watcher. However, since our beforeClose property is async, there is a delay before the property is reverted which leads to unwanted animation changes.

Jun-02-2023 11-51-13

If the beforeClose takes any significant time it will basically close the modal and reopen it. The shifting is even noticeable with a function that just returns a resolved promise.

I think I lean towards not having the watcher flip the property for this reason. What do you think? If we don't flip the property, users will just have to call beforeClose before toggling the property.

@driskull driskull marked this pull request as ready for review June 5, 2023 16:47
@driskull driskull requested a review from a team as a code owner June 5, 2023 16:47
@driskull driskull added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Jun 5, 2023
Copy link
Member

@benelan benelan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, but some people may see this as a breaking change since they may be relying on this behavior. I'll wait for Franco for final review due to that.

Nitpick: can you change "should" to "does" in the PR title. Or: "... property no longer calls beforeClose"

@driskull driskull changed the title fix(modal): changing the open property should not call beforeClose fix(modal): changing the open property no longer calls beforeClose Jun 7, 2023
@driskull driskull requested a review from jcfranco June 14, 2023 23:50
@driskull driskull added this to the 2023 June patch priorities milestone Jun 16, 2023
@driskull
Copy link
Member Author

Something else that we could do instead of this would be to introduce an internal state that handles the open prop as well as the beforeClose. So if a user sets the open prop to false it won't actually close until both the open prop and beforeClose have resolved. That would eliminate any temporary style changes. We would likely need to update our CSS to not use the open attribute and use a class instead.

@jcfranco is this what you want to pursue?

@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity. Please close your PR if it is no longer relevant. Thank you for your contributions.

@github-actions github-actions bot added the Stale Issues or pull requests that have not had recent activity. label Jul 22, 2023
@driskull
Copy link
Member Author

driskull commented Aug 3, 2023

Ping @jcfranco

@driskull driskull closed this Aug 7, 2023
@driskull driskull deleted the dris0000/modal-beforeClose-fix branch August 7, 2023 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports for broken functionality. Issues should include a reproduction of the bug. pr ready for visual snapshots Adding this label will run visual snapshot testing. Stale Issues or pull requests that have not had recent activity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants