From 827b58e7aca8c19e61c3628eab77fd30a5170027 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Wed, 5 Dec 2018 13:48:07 +0000 Subject: [PATCH] remove the unknown button in js When you hit enter while an input in a form is in focus, your browser finds the first button in the form, and carries out that action. So, for non-js users, we added a hidden submit button with a value of "unknown" to reflect that we don't know the intention of the user. However, with JS enabled, this ambiguity doesn't exist - there's only submit button and forms to fill in at a time, and non-visible fields aren't even submitted at all. We can remove the unknown button, supporting enter as submit properly. If the user is on one of the grey button states, with no submit, it'll press the first button, and go to the new template / move to existing folder dialog. That's fine enough. --- app/assets/javascripts/templateFolderForm.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/javascripts/templateFolderForm.js b/app/assets/javascripts/templateFolderForm.js index 3b223d424..335a66115 100644 --- a/app/assets/javascripts/templateFolderForm.js +++ b/app/assets/javascripts/templateFolderForm.js @@ -6,6 +6,10 @@ this.start = function(templateFolderForm) { this.$form = $(templateFolderForm); + // remove the hidden unknown button - if you've got JS enabled then the action you want to do is implied by + // which field is visible. + this.$form.find('button[value=unknown]').remove(); + this.$stickyBottom = this.$form.find('#sticky_template_forms'); this.$stickyBottom.append(this.nothingSelectedButtons);