Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make [ENTER] default to submit the form #84

Merged
merged 1 commit into from
Apr 21, 2015
Merged

Make [ENTER] default to submit the form #84

merged 1 commit into from
Apr 21, 2015

Conversation

jechols
Copy link
Contributor

@jechols jechols commented Apr 14, 2015

Closes #82

@@ -8,8 +8,8 @@ var HydraEditor = (function($) {
this.options = options;

this.controls = $("<span class=\"input-group-btn field-controls\">");
this.remover = $("<button class=\"btn btn-danger remove\"><i class=\"icon-white glyphicon-minus\"></i><span>Remove</span></button>");
this.adder = $("<button class=\"btn btn-success add\"><i class=\"icon-white glyphicon-plus\"></i><span>Add</span></button>");
this.remover = $("<button type=\"button\" class=\"btn btn-danger remove\"><i class=\"icon-white glyphicon-minus\"></i><span>Remove</span></button>");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you need to give a button a type of button?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type is a valid attribute of button in HTML 5 but "The button has no default behavior." If scripting is the only way this button is useful, we could be preventing people who use assistive devices from using the form.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the why - that just happened to be the recommended fix for browsers to know what to do on hitting [ENTER] when a form had lots of buttons.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also on the page @mtribone mentioned:

The type of the button. Possible values are: submit: The button submits the form data to the server. This is the default if the attribute is not specified, or if the attribute is dynamically changed to an empty or invalid value.

So we probably should set it to type=button 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, haha, I should have read that :)

@jcoyne
Copy link
Member

jcoyne commented Apr 15, 2015

This seems like a rather drastic change. I'd like to have someone from the Sufia camp review this.
/cc @Cam156 @mjgiarlo @awead @hectorcorrea

@awead
Copy link
Contributor

awead commented Apr 15, 2015

I think this should follow what the useability standards are, which I would think would be to submit the form. @mtribone knows a bit more about this. Maybe he and weigh in too.

@hectorcorrea
Copy link
Member

I've been puzzled myself on the current behavior of our forms when hitting ENTER. I like the idea of using the default browser behavior (submit) but definitively would like to hear @mtribone's thoughts.

}
});
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah our forms need a good looking into for usability/accessibility. So this code removes the default ability to add and remove metadata by hitting the enter key and gives it only to the button that submits the form. Does this mean that I have to use my mouse throughout the form to add and remove metadata or select items from a dropdown? And then get to use the enter key only to submit the form? If I'm following along, I think that there might be a better way to approach submitting the form using only a keyboard.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the spacebar also works to activate controls. So if we bind the enter key to submit the form, this might be alright. I'm going to ping our local accessibility people and see how they navigate forms and activate controls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I have been tabbing to the button and hitting enter, as opposed to using the mouse. The button is always one tab away from the input field, so it's pretty easy to get to. The submit button was the tough one to navigate to since our forms are currently very big (and most fields are optional).

I'm not a keyboard-only user, mind you, I just happen to avoid the mouse as much as I can due to wrist issues. Leaving the hands in one spot is just easier.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. If you can keep your hands on the keys, why wouldn't you want to keep them there. And holy crow our forms are long! We might be able to alleviate that a little bit by adding tabindex values to jump over optional fields, but that might create additional problems. Or just redesign the forms. :-)

Let me double check on the spacebar/enter key usage and then I think we're good to go.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting mixed results on the enter key and spacebar issue. I'd say "go for it" since it possibly alleviates accidentally deleting metadata depending on where the focus happens to be in the form.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering what the preferred way would be to submit the form if ENTER were to default to the buttons. I'd think they would want some kind of option to submit in a single keystroke, but maybe I'm just nuts here. Or maybe there are assistive tools that render it a non-issue...? As a mostly-but-not-100%-keyboard user, I can only comment on people like me who prefer the keyboard, but aren't forced to use it exclusively.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They have to tab through everything to focus on it, so they can hear what it is before they use it. However, we can create access keys to get people directly to the submit button rather than tabbing through the whole thing. We also need to inform people ahead of time that we have some controls mapped to certain things

http://webaim.org/techniques/keyboard/accesskey#spec

So if we bind enter to the submit button, we should instruct folks at the top of the form to use the spacebar for the add/remove buttons, a defined access key, and enter to submit the form.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so it sounds like there's more accessibility work to be done. Did you want me to put that stuff together in this PR? Or can this be merged and a new PR be made for addressing the other issues?

It sounds like everybody agrees that "enter submits form" is better than "enter clicks nearest button", at least.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say let's put the accessibility work into another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll start on another PR for the rest of the accessibility stuff. @mjgiarlo, @jcoyne - is this reasonable to merge?

@mjgiarlo
Copy link
Member

👍

@mjgiarlo
Copy link
Member

Any further thoughts, @jcoyne @mtribone @awead @hectorcorrea? I'm 👍 to merging, methinks.

@mtribone
Copy link

@mjgiarlo I would have already pushed the button if I had wizard class permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ENTER] key not intuitive
6 participants