Closed datasushi closed 3 years ago
Hi @datasushi, Not sure what you mean by handling Enter, Bootstrap Modals do not respond to Enter either: https://getbootstrap.com/docs/5.1/components/modal/#how-it-works
Is this custom behavior you need, or do you mean something like autofocusing an inner button like this? https://svelte.dev/repl/aac847deb62844f6ac31716c0354b09f?version=3.42.1
If so, it seems like autofocus could be improved, I had to do some weird stuff above to get it all to work.
Hey @bestguy thanks for taking the time to look into this. Haven't checked Bootstrap but if BS doesn't have anything out of the box then it makes sense that Sveltestrap doesn't either.
About your REPL, yes that's exactly the kind of thing I was looking for, it would be great if Svelte supported actions for components. I have built a different workaround , you can check it out here if you want: https://svelte.dev/repl/e4a8bee2a84d44599a452d932a96b676?version=3.42.1
For focus it would be very helpful if the sveltestrap components supported bind:this, you could then just call el.focus() in onmount(). I have added to the REPL for illustration, but it doesn't work. I have seen other components do it this way.
Anyways, with regards of the initial question I have what I need, thanks again.
Hi, not sure if I am missing something but it seems like the modals listen to "escape" keydown events and close on them, for "enter" events however there doesn't seem to be anything out of the box.
I have tested using the following REPL to make sure it's not focus or something else. In the REPL you can click on the Open button and then into the modal, when pressing escape the modal will close, when pressing enter nothing happens. https://svelte.dev/repl/e4a8bee2a84d44599a452d932a96b676?version=3.42.1
I know how to build a workaround but was wondering if there is a "proper" way of doing it. I have noticed that on your demo page it works.
Thanks a lot!