Skip to content

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

igardev
Copy link
Contributor

@igardev igardev commented May 22, 2025

Replace alert and confirm with custom modals. This is needed as Webview in VS Code doesn't permit alert and confirm for security reasons.

Copy link
Collaborator

@ngxson ngxson left a 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]">
Copy link
Collaborator

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]">
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

@igardev
Copy link
Contributor Author

igardev commented May 22, 2025

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
}

I think I understand what you mean. Will try to do it tomorrow.

@igardev
Copy link
Contributor Author

igardev commented May 23, 2025

@ngxson I've changed it to simplify the usage of custom modals.
Just for information - I've noticed that in full screen I don't see the "..." button for the conversations in the sidebar and can't resize the sidebar to show it.

@igardev igardev force-pushed the webui_use_custom_confirm branch from a07b5d6 to 7eabfe5 Compare May 23, 2025 21:30
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