Skip to content
Snippets Groups Projects
Commit 3d8ccbe2 authored by Robert Phillips's avatar Robert Phillips
Browse files

Issue #3309894 by robphillips: Set is-filled when input is not empty.

parent d097ead5
Branches
Tags 1.1.3
No related merge requests found
......@@ -43,6 +43,14 @@
this.choices.containerOuter.element.classList.remove("is-filled");
}
});
element.addEventListener("search", () => {
this.choices.containerOuter.element.classList.add("is-filled");
});
this.choices.input.element.addEventListener("change", () => {
if (!this.hasValues() && !this.choices.input.element.value) {
this.choices.containerOuter.element.classList.remove("is-filled");
}
});
// Set default choice labels.
if (labels) {
......@@ -117,12 +125,16 @@
/**
* Check if value(s) exist.
*
* @returns {true|false}
* @return {true|false}
* Returns TRUE or FALSE.
*/
hasValues() {
const values = this.choices.getValue();
return (Array.isArray(values) && values.length) || (!Array.isArray(values) && values);
return (
this.choices.input.element.value ||
(Array.isArray(values) && values.length) ||
(!Array.isArray(values) && values)
);
}
/**
......
......@@ -38,6 +38,14 @@
this.choices.containerOuter.element.classList.remove("is-filled");
}
});
element.addEventListener("search", () => {
this.choices.containerOuter.element.classList.add("is-filled");
});
this.choices.input.element.addEventListener("change", () => {
if (!this.hasValues() && !this.choices.input.element.value) {
this.choices.containerOuter.element.classList.remove("is-filled");
}
});
if (labels) {
const {
......@@ -92,7 +100,7 @@
hasValues() {
const values = this.choices.getValue();
return Array.isArray(values) && values.length || !Array.isArray(values) && values;
return this.choices.input.element.value || Array.isArray(values) && values.length || !Array.isArray(values) && values;
}
isMax() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment