Skip to content

Commit 08eb130

Browse files
authored
Resolved previous color selection i,e issue #111
1 parent cfaa22c commit 08eb130

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

js/ColorModule.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,15 @@ const ColorModule = (() => {
158158
*/
159159
function addColorButtonEvent() {
160160
//generate random color
161-
const newColor = new Color("hsv", Math.floor(Math.random()*360), Math.floor(Math.random()*100), Math.floor(Math.random()*100)).hex;
162-
163-
//remove current color selection
164-
document.querySelector('#colors-menu li.selected')?.classList.remove('selected');
161+
const newColor = new Color("hsv", Math.floor(Math.random()*360), Math.floor(Math.random()*100), Math.floor(Math.random()*100)).hex;
165162

166163
//add new color and make it selected
167164
let addedColor = addColor(newColor);
168165
addedColor.classList.add('selected');
166+
167+
//remove previous color selection
168+
document.querySelector('#colors-menu li.selected')?.classList.remove('selected');
169+
169170
addedColor.style.width = squareSize + "px";
170171
addedColor.style.height = squareSize + "px";
171172
updateCurrentColor(newColor);

0 commit comments

Comments
 (0)