-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add hidden submit button #6472
Add hidden submit button #6472
Conversation
@@ -34,6 +34,7 @@ | |||
note = "" | |||
<h2 class="editFormTitle">$:title</h2> | |||
$if ctx.user and (ctx.user.is_admin() or ctx.user.is_librarian()): | |||
<button type="submit" class="hidden" name="_save" form="addWork" tabindex="-1"></button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep; can't find a better solution. Because the consequences of this are a little extreme, let's see if we can avoid this happening in the future!
Could you (1) create a $def
like render_submit_button(hidden=False)
, so that the two submit buttons always have the correct values? I.e. DRY up their rendering logic. No need for this to be a separate file of course!
And (2) try placing the hidden button as the first element in the addWork
<form>
. That should hopefully prevent this issue from ever happening again!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and (3) add a comment about why it's necessary; so some future person doesn't "helpfully" delete the "unused hidden button"
openlibrary/macros/EditButtons.html
Outdated
@@ -1,4 +1,4 @@ | |||
$def with (comment=None) | |||
$def with (comment=None, submit_markup='') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro is referenced in a BUNCH of other places ; we can't modify it like this -- you know unless we do want to delete the Save button on every page but the book page :P It's a good idea to check for usages of a template/function whenever modifying its arguments. I'm going to roll back the last commit 👍
6402233
to
ef5892b
Compare
4d46f69
to
29027bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested:
- ✅ Pressing enter saves for librarians and non-librarians (FF, Chrome, IE)
- ✅ Pressing delete deletes (FF, Chrome)
- Doesn't work in IE, but since librarian only feature, doesn't need to be IE-compatible.
@jimchamp The DRY-ing of the submit buttons doesn't appear to be worth it because there's another template in the way, so ignoring. I was able to move the submit button up to the top of the template. I missed that it wasn't inside the |
Closes #6471
Adds a hidden submit button prior to the "Delete" submit button.
Technical
A form's first submit button is triggered when
enter
is pressed. PR #6273 linked the previously broken top-of-page delete button to the form, making it the form's first submit button.Testing
Screenshot
Stakeholders