Skip to content

Commit

Permalink
Enter in attribute value focuses attribute selector instead of form post
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Oct 20, 2018
1 parent d1ec642 commit b34e051
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mujina-idp/src/main/resources/public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ document.addEventListener("DOMContentLoaded", function () {
var spanId = guid();
var inputId = guid();
newElement.innerHTML = "<label>" + val + "</label>" +
"<input type='text' id='" + inputId + "' name='" + val + "'></input>" +
"<input class='input-attribute-value' type='text' id='" + inputId + "' name='" + val + "'></input>" +
"<span id='" + spanId + "' class='remove-attribute-value'>🗑</span>";
document.getElementById("attribute-list").appendChild(newElement);
document.getElementById(spanId).addEventListener("click", function () {
Expand All @@ -58,7 +58,15 @@ document.addEventListener("DOMContentLoaded", function () {
}
select.value = "Add attribute...";
setTimeout(function () {
document.getElementById(inputId).focus();
var inputElement = document.getElementById(inputId);
inputElement.focus();
inputElement.addEventListener("keypress", function(e){
if (e.code === "Enter") {
e.stopPropagation();
e.preventDefault();
select.focus();
}
});
}, 25);
});
});

0 comments on commit b34e051

Please sign in to comment.