in src/plugin/fieldViews/DropdownFieldView.ts [49:69]
protected createInnerView(chosenOption: string): void {
this.dropdownElement = document.createElement("select");
// Add a child option for each option in the array
for (const option of this.options) {
const domOption = this.optionToDOMnode(option, chosenOption);
this.dropdownElement.appendChild(domOption);
}
// Add a listener that will return the state of the dropdown on change
this.dropdownElement.addEventListener("change", (e) => {
const dropdownNode = e.target as HTMLSelectElement;
const domOptions = Array.from(dropdownNode.options);
const selectedOption = domOptions.find((option) => option.selected);
this.updateOuterEditor(
selectedOption ? JSON.parse(selectedOption.value) : chosenOption
);
});
this.fieldViewElement.appendChild(this.dropdownElement);
}