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

Modal: Close is a promise + onClickOutside #5325

Merged
merged 1 commit into from
Oct 28, 2024
Merged

Conversation

estib-vega
Copy link
Contributor

☕️ Reasoning

Enhance modal functionality by making the closing process a promise and adding an optional callback for clicking outside the modal.

🧢 Changes

Make the modal closing function a promise as it's done asynchronously.
Add another optional callback that's called only in the case when clicking outside the modal.
Copy link

vercel bot commented Oct 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitbutler-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 10:35am

@@ -52,14 +63,20 @@
window.addEventListener('keydown', handleKeyDown);
}
export function close() {
export function close(): Promise<void> {
if (isClosing) return Promise.resolve();
Copy link
Contributor

Choose a reason for hiding this comment

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

If this function is called twice, then it looks to me like the second call would resolve immediately while the original resolves in 100ms. Is this intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. Makes sense to resolve the promise only until it's fully closed, regardless of if the function is called a second time

@estib-vega estib-vega merged commit 40d6c2d into master Oct 28, 2024
15 checks passed
@estib-vega estib-vega deleted the modal-improvements branch October 28, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants