From bf099d8f54d166c8719221290f5db56ab1b8cecc Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand <benjamin.bertrand@esss.se> Date: Mon, 18 Dec 2017 11:38:47 +0100 Subject: [PATCH] Auto-scroll to item comment form Scroll up to ensure the from input is not hidden below the navbar. See https://github.com/twbs/bootstrap/issues/1768 --- app/static/js/items.js | 6 ++++++ app/templates/inventory/view_item.html | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/static/js/items.js b/app/static/js/items.js index 7a5c373..72a71bc 100644 --- a/app/static/js/items.js +++ b/app/static/js/items.js @@ -1,5 +1,11 @@ $(document).ready(function() { + // scroll up to avoid having the form input + // hidden under the navbar + if (location.hash == "#text") { + scrollBy(0, -100); + } + var converter = new showdown.Converter({ simplifiedAutoLink: true }); diff --git a/app/templates/inventory/view_item.html b/app/templates/inventory/view_item.html index 865d8d6..0eb5e18 100644 --- a/app/templates/inventory/view_item.html +++ b/app/templates/inventory/view_item.html @@ -62,7 +62,7 @@ <div class="card-body item-comment">{{ comment.text }}</div> </div> {% endfor %} - <a class="btn btn-primary" href="{{ url_for('inventory.comment_item', ics_id=item.ics_id) }}">Comment</a> + <a class="btn btn-primary" href="{{ url_for('inventory.comment_item', ics_id=item.ics_id) }}#text">Comment</a> <hr> -- GitLab