From 3d432d2b46198e84fb4f128806ef762243504873 Mon Sep 17 00:00:00 2001 From: Leesa Ward Date: Fri, 22 Jul 2022 19:05:18 +1000 Subject: [PATCH] Add is-open class to the button when dropdown is open Enables styling for the button specific to the open state, such as rotating the arrow. --- src/javascript/vanilla-js-dropdown.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/javascript/vanilla-js-dropdown.js b/src/javascript/vanilla-js-dropdown.js index 4412959..6da510d 100644 --- a/src/javascript/vanilla-js-dropdown.js +++ b/src/javascript/vanilla-js-dropdown.js @@ -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(); } @@ -137,6 +137,7 @@ var CustomSelect = function(options) { */ function toggle() { ul.classList.toggle(openClass); + button.classList.toggle(openClass); } /** @@ -146,6 +147,7 @@ var CustomSelect = function(options) { */ function open() { ul.classList.add(openClass); + button.classList.add(openClass); } /** @@ -155,6 +157,7 @@ var CustomSelect = function(options) { */ function close() { ul.classList.remove(openClass); + button.classList.remove(openClass); } return {