Skip to content

Commit

Permalink
Add is-open class to the button when dropdown is open
Browse files Browse the repository at this point in the history
Enables styling for the button specific to the open state, such as rotating the arrow.
  • Loading branch information
doubleedesign authored Jul 22, 2022
1 parent 83810dd commit 3d432d2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/javascript/vanilla-js-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ var CustomSelect = function(options) {

var t = e.target; // || e.srcElement; - uncomment for IE8

if (t.className === titleClass) {
if (t.className.includes(titleClass)) {
toggle();
}

Expand Down Expand Up @@ -137,6 +137,7 @@ var CustomSelect = function(options) {
*/
function toggle() {
ul.classList.toggle(openClass);
button.classList.toggle(openClass);
}

/**
Expand All @@ -146,6 +147,7 @@ var CustomSelect = function(options) {
*/
function open() {
ul.classList.add(openClass);
button.classList.add(openClass);
}

/**
Expand All @@ -155,6 +157,7 @@ var CustomSelect = function(options) {
*/
function close() {
ul.classList.remove(openClass);
button.classList.remove(openClass);
}

return {
Expand Down

0 comments on commit 3d432d2

Please sign in to comment.