Skip to content

Commit

Permalink
Fix multiple datalists for similar autocompletes
Browse files Browse the repository at this point in the history
* Fix multiple datalists for same autocompletes
  • Loading branch information
ninedev-i authored Nov 28, 2024
1 parent cf63b2f commit fef52c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
22 changes: 13 additions & 9 deletions app/scripts/json-editor/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ export default function makeAutocompleteEditor(options = []) {
}

addDatalist(options) {
this.datalist = document.createElement('datalist');
this.datalist.id = 'options-datalist';
const datalistId = 'options-datalist';
this.input.setAttribute('list', datalistId);

options.forEach((optionValue) => {
const option = document.createElement('option');
option.value = optionValue;
this.datalist.appendChild(option);
});
// Since we have autocomplete only for devices it is enough to have only one datalist for multiple similar inputs
if (!this.jsoneditor.element.querySelector(`#${datalistId}`)) {
const datalist = document.createElement('datalist');
datalist.id = datalistId;

this.input.setAttribute('list', this.datalist.id);
options.forEach((optionValue) => {
const option = document.createElement('option');
option.value = optionValue;
datalist.appendChild(option);
});

this.container.appendChild(this.datalist);
this.jsoneditor.element.appendChild(datalist);
}
}
};
}
10 changes: 8 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
wb-mqtt-homeui (2.105.4) stable; urgency=medium

* Fix multiple datalists for same autocompletes

-- Victor Vedenin <[email protected]> Thu, 28 Nov 2024 08:58:11 +0300

wb-mqtt-homeui (2.105.3) stable; urgency=medium

* Fix device selection on scan page in wb-mqtt-serial config editor
Expand Down Expand Up @@ -85,7 +91,7 @@ wb-mqtt-homeui (2.102.0) stable; urgency=medium

wb-mqtt-homeui (2.101.1) stable; urgency=medium

* Do not collapse white spaces in rules console messages
* Do not collapse white spaces in rules console messages

-- Petr Krasnoshchekov <[email protected]> Wed, 16 Oct 2024 12:33:18 +0500

Expand All @@ -109,7 +115,7 @@ wb-mqtt-homeui (2.100.4) stable; urgency=medium
-- Victor Vedenin <[email protected]> Fri, 04 Oct 2024 15:55:01 +0300

wb-mqtt-homeui (2.100.3) stable; urgency=medium

* Remove type filter from widgets

-- Victor Vedenin <[email protected]> Thu, 03 Oct 2024 16:20:24 +0300
Expand Down

0 comments on commit fef52c9

Please sign in to comment.