Fix double tag input on back button

This commit is contained in:
Mark Veidemanis 2022-08-09 07:20:30 +01:00
parent 09e748db73
commit 62133a8cbb
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
2 changed files with 8 additions and 4 deletions

View File

@ -362,9 +362,6 @@
</div> </div>
<div class="block"> <div class="block">
<input id="tags" class="input" type="tags" placeholder="Add query" value="{{ tags|joinsep:',' }}"> <input id="tags" class="input" type="tags" placeholder="Add query" value="{{ tags|joinsep:',' }}">
<script>
setupTags();
</script>
</div> </div>
<div class="block"> <div class="block">
<div id="results"> <div id="results">

View File

@ -203,7 +203,14 @@
var inputTags = document.getElementsByClassName('tags-input'); var inputTags = document.getElementsByClassName('tags-input');
var inputBox = document.querySelector("[placeholder='Add query']"); var inputBox = document.querySelector("[placeholder='Add query']");
var isFocused = (document.activeElement === inputBox); var isFocused = (document.activeElement === inputBox);
for (index = 0; index < inputTags.length; index++) {
if (index == 0) {
inputTags[0].outerHTML = '<input id="tags" class="input" type="tags" placeholder="Add query" value="{{ tags|joinsep:',' }}">'; inputTags[0].outerHTML = '<input id="tags" class="input" type="tags" placeholder="Add query" value="{{ tags|joinsep:',' }}">';
} else {
inputTags[index].remove();
}
}
// inputTags[0].outerHTML = '<input id="tags" class="input" type="tags" placeholder="Add query" value="{{ tags|joinsep:',' }}">';
setupTags(); setupTags();
var inputBox = document.querySelector("[placeholder='Add query']"); var inputBox = document.querySelector("[placeholder='Add query']");
if (isFocused) { if (isFocused) {