Skip to content

Commit

Permalink
fix: add active when an option is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Jul 9, 2021
1 parent cf00928 commit 2eb086e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ cc-options, .options {
-webkit-animation: hideAnimation 0.4s ease-out;
}


cocreate-select.open .options {
cocreate-select.open .options, cocreate-select.open cc-options {
/*display:flex;*/
flex-direction:column;
max-height: 50vh;
Expand Down
4 changes: 4 additions & 0 deletions src/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ CoCreateSelect.prototype = {
if (this.input)
this.input.value = ""
this.selectContainer.classList.remove('open');
if (!this.selectedContainer.children.length)
this.selectContainer.classList.remove('active');
this.selectContainer.dispatchEvent(new CustomEvent('CoCreateSelect-close'));
},
getOptions: function() {
Expand Down Expand Up @@ -188,6 +190,7 @@ CoCreateSelect.prototype = {
// todo: when an option is not found. just use option itself and remvove these lines
optionToSelected.set(selectedOption, selectedOption);
selectedToOption.set(selectedOption, selectedOption);
this.selectContainer.classList.add('active');
}
else {
value = option.getAttribute('value');
Expand All @@ -198,6 +201,7 @@ CoCreateSelect.prototype = {
option.setAttribute('selected', "");
optionToSelected.set(option, selectedOption);
selectedToOption.set(selectedOption, option);
this.selectContainer.classList.add('active');
}

selectedOption.appendChild(removeElement.cloneNode(true));
Expand Down

0 comments on commit 2eb086e

Please sign in to comment.