theigl commented on PR #1076:
URL: https://github.com/apache/wicket/pull/1076#issuecomment-2597676579

   Let's take a step back and think about this once again.
   
   1. The original behavior prior to your PR #971 was that forms could not be 
submitted via ENTER from multiline fields. This is what I would consider 
"default" browser behavior.
   2. Your first PR changed that and forms can now be submitted via ENTER from 
multiline fields. This is problematic.
   3. This PR now attempts to solve this by making the submit handling 
configurable and restoring the original behavior.
   
   For me, this PR is doing too many things. I think we should simply restore 
the original behavior. Submitting a form from multiline fields is something 
that is rarely needed, and if it is needed it can be easily added to a textarea 
as a behavior. We are using this in our project:
   
   ```java
   public final class KeyboardSubmitBehavior extends WiQueryEventBehavior {
   
        private static final String SUBMIT_SELECTOR = 
"input[type='submit'],button[type='submit'],[name=':submit']";
   
        public KeyboardSubmitBehavior(final KeyboardEvent keyboardEvent) {
                super(new Event(KeyboardEvent.KEYDOWN) {
                        @Override
                        public JsScope callback() {
                                return JsScopeEvent.quickScope("if 
((event.which == 10 || event.which == 13) && event.ctrlKey) { " +
                                                
"$(this).closest('form').find(\"" + SUBMIT_SELECTOR + "\").trigger('click'); 
return false; " +
                                                "}");
                        }
                });
        }
   }
   ```
   
   Then we don't need a separate `form.js` file and most of the complexity goes 
away.
   
   What do you think @solomax and @martin-g?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to