Comments (12)
Thanks for the details, indeed both of your issues might be related to the fact it doesn't have a parent window, or rather, that it doesn't take account of the parentWindow argument when used in a renderer process context. I never used it outside of the main process, so i'm not sure what exactly is going on. Could you make sure that the prompt fonction pass a coherent parentWindow value to the browserWindow constructor ?
from electron-prompt.
@sperrichon Have you been able to initiate the prompt from a renderer process, attaching it to the parent window via remote.getCurrentWindow() ?
I thought that would solve it, but it doesn't :(
In that case, can you provide the code?
I will look into making a minimal project example
from electron-prompt.
Could you tell me with more details what you're expecting and what actually happens?
from electron-prompt.
The expected behavior is when the main app has been closed/terminated, the prompt should also terminate.
It doesnt, perhaps somehow related to not having a parent window?
To replicate:
- open prompt
- without closing it, close the main app
It doesnt close, and when you try to close it - you get javascript error:
Attempting to call a function in renderer window that has been closed or released...
from electron-prompt.
Ah I see.
console.log(remote.getCurrentWindow())
does give me a valid window object
but when using
parentWindow :remote.getCurrentWindow()
I get
F:\stuff\elAPP\node_modules\electron-prompt\lib\index.js:38 Uncaught TypeError: Converting circular structure to JSON
and the prompt doesnt even initialize properly
from electron-prompt.
I also tried passing the main window from main.js as a variable to the renderer on initialization.
I get the same problems, but at least the prompt initializes
from electron-prompt.
Ok, I passed it like this and I didnt get any errors:
prompt({
title: 'Create New Chapter',
label: 'Please enter the new Chapters Name:',
value: 'new',
//// parentWindow : parentMainWindow, <<- wrong way?
inputAttrs:{type: ''}},
remote.getCurrentWindow()) //<<- right way?
.then((newname) => {
console.log('result', newname); // null if window was closed, or user clicked Cancel
if (newname.length==0){alert("You didnt enter a name");return};
createNew(newname);
}).catch(console.error);
But that doesnt resolve the issue here. The prompt doesnt get terminated when I close the app
from electron-prompt.
I have not been able to replicate the error, could you provide me a working example of code that can trigger the error when the "window has been released" ?
from electron-prompt.
I have not been testing anything, tho I intend to try something too later today
from electron-prompt.
Fixed by PR #16
from electron-prompt.
Thank you for the fix 👍 :)
I will test this again when I have some time
from electron-prompt.
no problem, feel free to reopen the issue in case the problem would not totally resolved.
from electron-prompt.
Related Issues (20)
- electron-prompt cannot be used if I compile a exe program
- Error: Image could not be created from \n HOT 2
- Suggestion : Allow 'minimizable' for BrowserWindow in opts HOT 1
- Include a LICENSE file at the root of the repo HOT 4
- Validate form on Enter/return key pressed HOT 5
- Feature Request: allow creating an inescapable prompt HOT 1
- If you're using this in electron-react-boilerplate...
- Prompt window closes immediately for some Linux users HOT 2
- Preview electron-prompt HOT 2
- Label and Input issue HOT 3
- ERR_FILE_NOT_FOUND (-6) loading HOT 1
- [feature request]Add a 'swapButtons' option
- Add typescript support? (`d.ts` file) HOT 2
- Use `@electron/remote` instead of importing it from `electron` as it will be deprecated in Electron version 14 HOT 5
- testing example prompt: label and input field not displayed, cancel and ok buttons unstyled HOT 2
- Issue with promise HOT 1
- Add support for MacBook's touchbar
- Using a single JS file to do the prompt
- Can't make it work with Electron 19
- [feature request] Multi prompt for example having 2 or 3... input forms
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-prompt.