Skip to content

Commit

Permalink
Sorted the options in the dropdown lists alphabetically on the option…
Browse files Browse the repository at this point in the history
…s text field
  • Loading branch information
TyroneAEM committed Jun 27, 2024
1 parent 0a413be commit 2baf5ba
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions blocks/gmo-program-header/gmo-program-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ function attachEventListeners() {

function populateDropdown(response, dropdownId, type) {
const options = response.data?.jsonByPath ? response.data.jsonByPath.item.json.options : response;
//Sort the options alphabetically
options.sort((a, b) => {
if (a.text < b.text) {
return -1;
}
if (a.text > b.text) {
return 1;
}
return 0;
});

let dropdownContent = document.getElementById(dropdownId);
dropdownContent.innerHTML = '';
options.forEach((option, index) => {
Expand Down

0 comments on commit 2baf5ba

Please sign in to comment.