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

Why prompt is not supported? #472

Closed
coderaiser opened this issue Jul 9, 2014 · 40 comments
Closed

Why prompt is not supported? #472

coderaiser opened this issue Jul 9, 2014 · 40 comments

Comments

@coderaiser
Copy link

coderaiser commented Jul 9, 2014

What is the reason that prompt is not supported?

How could input box be created?
I see that prompt could be almost like confirm:

window.confirm = (message, title='') ->
  remote = require 'remote'
  dialog = remote.require 'dialog'
  buttons = ['OK', 'Cancel']
  not dialog.showMessageBox remote.getCurrentWindow(), {message, title, buttons}

Here is possible solution.

@Subash
Copy link

Subash commented Jul 10, 2014

Prompt blocks the thread while inputting data from the user so i guess that is the main reason.

@coderaiser
Copy link
Author

Same thing with alert and confirm and any dialog made with dialog api. I do not think that is a reason, sometimes this blocking is necessary (like when someone choose file to open).

@batjko
Copy link
Contributor

batjko commented Jul 21, 2014

It would be interesting to know whether the vex library, which aims to replace the core dialogs, can circumvent that restriction.

@zcbenz
Copy link
Member

zcbenz commented Oct 26, 2014

There is no native prompt dialogs in most GUI toolkits, so implementing prompt in atom-shell would require writing the prompt dialog from ground up on all platforms. Due to the rare use of prompt, I think it doesn't deserve to do all the work, and it is very easy to use a web implemented solution for this.

So I'm closing this as won't fix.

@coderaiser
Copy link
Author

coderaiser commented Sep 26, 2015

Possible solution: Promise-based Alert, Confirm and Prompt replacement.
confirm

@alexandrev
Copy link

+1 and related to: #4134

@feross
Copy link
Contributor

feross commented Mar 3, 2016

It seems that on OS X at least, it can't be that hard to support a prompt-like dialog box, since Transmission does it:

screen shot 2016-03-02 at 4 24 05 pm

@konsumer
Copy link

I made one that works just like the browser window.prompt using preload & a synchronous IPC call. Check it out here. It could use some styling, but you get the idea. (here are my changes.)

var name = prompt('What is your name?', 'David')

prompt

@konsumer
Copy link

This looks like a "fake" prompt in the window, but it's a separate blocking synchronous window, just like prompt.

@konsumer
Copy link

konsumer commented Jul 28, 2016

Those are fake, in the sense that it's inside the window. Mine are outside if it.

@msudgh
Copy link

msudgh commented Jul 28, 2016

Hi, Is there any way for this issue?

@noahbenham
Copy link

noahbenham commented Dec 5, 2016

FYI for those considering @JamesKyburz's link, the Github page states the solution is not allowed in electron and some chrome extention contexts.

Edit: Nevermind, misread documentation. Thanks for the correction @JamesKyburz.

@JamesKyburz
Copy link
Contributor

@noahbengam

No, https://github.com/jameskyburz/dialogs is a fix in response to alert, prompt, confirm not always being available.

From the readme:

Theses native counterparts block the UI thread, are are not allowed in electron and some chrome extention contexts.

@DRocksCoding
Copy link

DRocksCoding commented Jun 5, 2020

@gabrielstuff

https://codepen.io/gabrielstuff/pen/YoqvBr

Hey, thanks a lot man this is working! Its the best workaround for now.

But I agree with every other posts above that mentionned that a built-in prompt feature would be very useful to have implemented by Electron.

@gabrielstuff
Copy link

Since Dialogs are working fine and are fully customizable, I do not see why you would need prompt.

If you just want to use a shortcut, there are plenty of libs providing user inputs with JS solution and which are framework agnostics.

Enjoy Native Dialog :)

@ssight
Copy link

ssight commented Jun 14, 2020

For anybody who really wants native prompt windows in their Electron app, I've written this library. It's not perfect, but it gets the job done.

@blurymind
Copy link

blurymind commented Jun 14, 2020

We use this
https://sweetalert2.github.io/
It works both on electron and the pwa version of the app

@avin-shum
Copy link

Thank you @konsumer ! Still a good solution 4 years after published.

@andyfleming
Copy link

andyfleming commented Jan 8, 2021

I wish prompt was implemented. I'm developing an app and want to quickly capture some input. I just want something temporary, but now I'm left looking for a workaround for something that should just be built in. No one ever really wants to use prompt, but it's useful while developing.

@dperetti
Copy link

Same complaint here. Sometimes, quick & dirty is the way to go, especially when you're scaffolding something.

@dan-peterson
Copy link

For anybody who really wants native prompt windows in their Electron app, I've written this library. It's not perfect, but it gets the job done.

Thank you @ssight. Very well done.

@pjebs
Copy link

pjebs commented Jun 30, 2021

If you want consistency across different OS's, just use https://electron.guide/electron-alert/

It's powered by SweetAlert2.

@yunjimmy
Copy link

When we use the alert (1) in the Render Process,

In the Browser Window, it appears whether BrowserViews are occupying the screen.

Like the picture below.
image

However, the above libraries have lower priorities than BrowserView.

@Saturnine-Softworks
Copy link

Saturnine-Softworks commented Feb 7, 2023

Cannot believe this issue has been open since 2014. (Marked as closed, sure, but the problem has absolutely not been solved.)

@jonnycook
Copy link

I cannot for the life of me understand why confirm is supported but prompt is not. I don't want to be ungrateful for the hard work you guys have put into creating this platform, but don't you want it to be as easy to use and as valuable as possible?

@dandeancook
Copy link

dandeancook commented Jan 7, 2024

2024, i still can't understand why it's not supported, it's basic input!
while alert/confirm are working.

@laurent22
Copy link

laurent22 commented Jan 7, 2024

There is no native prompt dialogs in most GUI toolkits, so implementing prompt in atom-shell would require writing the prompt dialog from ground up on all platforms. Due to the rare use of prompt, I think it doesn't deserve to do all the work, and it is very easy to use a web implemented solution for this.

So I'm closing this as won't fix.

The reason for closing was strange too, and it mentions atom-shell, is that how Electron was called?

But Electron is based on Chromium and I'm sure Chromium already includes code for prompt so there's nothing to reimplement for each platform.

I think this issue, 10 years after it was created, should be reviewed again taking into account the current state of Electron.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests