-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Replace alert and confirm with custom modals. #13711
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this, I wanted to do it this way but don't yet have time.
However, just thinking, can we make this a react context provider? I think having a provider which provides a function equivalent to window.confirm/prompt
can make it easier to be reused in different places in the code base.
For example, in the code of deleteConversation
, we can do something like this:
// somewhere at the beginning of the component
const { showConfirm } = useDialog();
// then, inside the handler
if (await showConfirm()) {
// delete the conv
}
if (!isOpen) return null; | ||
|
||
return ( | ||
<div className="modal modal-open z-[1000]"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for a11y, this should be an element of type dialog
if (!isOpen) return null; | ||
|
||
return ( | ||
<div className="modal modal-open z-[1000]"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
I think I understand what you mean. Will try to do it tomorrow. |
@ngxson I've changed it to simplify the usage of custom modals. |
…ew in VS Code doesn't permit alert and confirm for security reasons.
a07b5d6
to
7eabfe5
Compare
Replace alert and confirm with custom modals. This is needed as Webview in VS Code doesn't permit alert and confirm for security reasons.