From cfa088634378a5f23db0ef949385b78066aafa1b Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Wed, 22 Jun 2022 19:59:32 +0300 Subject: [PATCH] fix: Make the IPR search form work when enter is pressed (#4114) --- ietf/static/js/ipr-search.js | 38 +++++++++++++++++------------ ietf/templates/ipr/search_form.html | 14 +++++------ 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/ietf/static/js/ipr-search.js b/ietf/static/js/ipr-search.js index 927848863..19f1a994a 100644 --- a/ietf/static/js/ipr-search.js +++ b/ietf/static/js/ipr-search.js @@ -1,8 +1,8 @@ $(document) .ready(function () { // hack the "All States" check box - $("#id_state") - .addClass("list-inline"); + $("#id_state .form-check") + .addClass("form-check-inline"); $("#id_state input[value!=all]") .on("change", function (e) { @@ -20,18 +20,24 @@ $(document) } }); - // make enter presses submit through the nearby button - // FIXME: this seems to be broken - $("form.ipr-search input,select") - .on("keyup", function (e) { - var submitButton = $(this) - .closest(".mb-3") - .find('button[type=submit]'); - if (e.which == 13 && submitButton.length > 0) { - submitButton.trigger("click"); - return false; - } else { - return true; - } + $("form.ipr-search button[type=submit]") + .on("click", function (e) { + const value = $(e.target) + .attr("value"); + $("form.ipr-search input[name=submit]") + .attr("value", value); }); - }); \ No newline at end of file + + // make enter presses submit through the nearby button + $("form.ipr-search input") + .on("keydown", function (e) { + if (e.key != "Enter") { + return; + } + e.preventDefault(); + $(this) + .closest(".input-group") + .find('button[type=submit]') + .trigger("click"); + }); + }); diff --git a/ietf/templates/ipr/search_form.html b/ietf/templates/ipr/search_form.html index b88bf5ba1..e35eafd26 100644 --- a/ietf/templates/ipr/search_form.html +++ b/ietf/templates/ipr/search_form.html @@ -13,7 +13,7 @@ {% bootstrap_label form.draft.label label_for=form.draft.id_for_label label_class="form-label" %}
{% render_field form.draft class="form-control" placeholder="draft-..." %} -
@@ -22,7 +22,7 @@ {% bootstrap_label form.rfc.label label_for=form.rfc.id_for_label label_class="form-label" %}
{% render_field form.rfc class="form-control" placeholder="123..." %} -
@@ -31,7 +31,7 @@ {% bootstrap_label form.doctitle.label|cut:":" label_for=form.doctitle.id_for_label label_class="form-label" %}
{% render_field form.doctitle class="form-control" placeholder="protocol..." %} -
@@ -42,7 +42,6 @@ {% render_field form.group class="form-select" %} @@ -53,7 +52,7 @@ {% bootstrap_label form.holder.label|cut:":" label_for=form.holder.id_for_label label_class="form-label" %}
{% render_field form.holder class="form-control" placeholder="John Doe..." %} -
@@ -62,7 +61,7 @@ {% bootstrap_label form.iprtitle.label|cut:":" label_for=form.iprtitle.id_for_label label_class="form-label" %}
{% render_field form.iprtitle class="form-control" placeholder="protocol..." %} -
@@ -71,7 +70,7 @@ {% bootstrap_label form.patent.label|cut:":" label_for=form.patent.id_for_label label_class="form-label" %}
{% render_field form.patent class="form-control" %} -
@@ -81,6 +80,7 @@ please enter the entire string, or as much of it as possible. +

The material posted as IPR disclosures should be viewed as originating