Git Product home page Git Product logo

Comments (10)

Fraasi avatar Fraasi commented on July 20, 2024

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.

p-sam avatar p-sam commented on July 20, 2024

Yup, this was introduced when I added form validation

from electron-prompt.

p-sam avatar p-sam commented on July 20, 2024

Can someone confirm me that behavior is back to normal on develop? Will do a minor release right after that

from electron-prompt.

edouardmercier avatar edouardmercier commented on July 20, 2024

@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.

p-sam avatar p-sam commented on July 20, 2024

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.

edouardmercier avatar edouardmercier commented on July 20, 2024

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.

p-sam avatar p-sam commented on July 20, 2024

Not sure why but your comments seem to be missing parts, specifically parts between quotes

from electron-prompt.

p-sam avatar p-sam commented on July 20, 2024

@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.

edouardmercier avatar edouardmercier commented on July 20, 2024

@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.

p-sam avatar p-sam commented on July 20, 2024

You can try doing a quick npm update, what does the package-lock.json says about the package?

from electron-prompt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.