mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Dropdowns now close when clicking outside of them
This commit is contained in:
@@ -19,17 +19,18 @@ export class Dropdown {
|
||||
this.setOptions(options);
|
||||
}
|
||||
|
||||
this.#value.addEventListener( "click", ev => {
|
||||
this.#element.classList.toggle( "is-open" );
|
||||
this.#value.addEventListener("click", (ev) => {
|
||||
this.#element.classList.toggle("is-open");
|
||||
this.#clip();
|
||||
});
|
||||
|
||||
this.#options.classList.add( "ol-scrollable" );
|
||||
document.addEventListener("click", (ev) => {
|
||||
if (!(this.#value.contains(ev.target as Node) || this.#options.contains(ev.target as Node) || this.#element.contains(ev.target as Node))) {
|
||||
this.#element.classList.remove("is-open");
|
||||
}
|
||||
});
|
||||
|
||||
// Commented out since it is a bit frustrating, particularly when the dropdown opens towards the top and not to the bottom
|
||||
//this.#element.addEventListener("mouseleave", ev => {
|
||||
// this.#close();
|
||||
//});
|
||||
this.#options.classList.add( "ol-scrollable" );
|
||||
}
|
||||
|
||||
setOptions(optionsList: string[])
|
||||
|
||||
Reference in New Issue
Block a user