Comments (10)
This has to do with the new version using <form>
, where enter submits the form.
Thus the keyup
event never fires and doesn't call promptSubmit
.
https://javascript.info/forms-submit
You can fix this simply by using keydown
event, which apparently fires before submit and prevents it. keypress
event on the other hand somehow fixed the enter
problem but broke using escape
.
It would propably be good to call e.preventDefault()
also, but I find it's not necessary here.
Weird problem, could someone else also test this just to make sure?
dataEl.addEventListener('keydown', e => {
if (e.key === 'Enter') {
// e.preventDefault()
promptSubmit();
}
if (e.key === 'Escape') {
promptCancel();
}
from electron-prompt.
Yup, this was introduced when I added form validation
from electron-prompt.
Can someone confirm me that behavior is back to normal on develop? Will do a minor release right after that
from electron-prompt.
@p-sam, a quick test on macOS shows that the modified code does not solve the issue: when hitting the "" key, the dialog box is still being considered as cancelled.
from electron-prompt.
What key? I tested the latest develop commit on OSX too
If you're trying from the npm package, please switch to the git repo on branch develop just for this test. I'm holding off from publishing a release until the fix is confirmed working (at least for you, others confirmation appreciated too)
from electron-prompt.
Sorry @p-sam, when using the dependency git://github.com/p-sam/electron-prompt#develop
for the electron-prompt
package, this does not work for me on macOS and electron
v7.1.9: indeed, once the dialog box with the text field is open and that I hit the "" key, the dialog is dismissed as if the "Cancel" button were pressed (instead of the "OK" button).
from electron-prompt.
Not sure why but your comments seem to be missing parts, specifically parts between quotes
from electron-prompt.
@edouardmercier The fix in ca0c3ad was tested on electron 7.1.10 and 7.1.9, on OSX too, and hitting the Enter key while in the text input submits the form, and returns me the result I typed, while hitting Esc returns null, as expected.
If you have any different result, I can't yet reproduce them because as I said, parts of your messages are missing. I will probably do a release later today, unless the fix is not enough in a particular OS/Electron ver combo.
from electron-prompt.
@p-sam, I have fixed my previous comment (which was buggy because I used incorrect Markdown). Thank you for having tested your fix on a similar environment as mine: if it is successful by you, this must mean that I must have made a mistake while using the develop
branch version.
from electron-prompt.
You can try doing a quick npm update
, what does the package-lock.json says about the package?
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.