The missing minor details

I have nearly finished a color flipper project that can successfully switch between two colors. However, there is this annoying bug that , while minor, is very noticeable.

When pressing the generate color button for the first time, you have to press the button twice, which is very noticeable.

Furthermore, when pressing generate color after switching state to complex and vice versa, the color selected isn’t a randomized color but rather a color from the array i made for the simple state.

This is the last of the minor kinks that I want to work out. Any help is appreciated. Thanks

Hi revenstar2,

the behavior that you described happens because you assign an onClickListener for your generateButton inside another onClickListener.

So you have two levels of onClickListener.

The simple remedy for that is to just have one onClickListener for your button. Just use the state variable inside this one onCLickListener.

Another minor thing: you can change the cursor of your mouse while hovering over your button.

Just add the CSS attribute cursor: pointer; to your h3 CSS selector.

best
Dennis

I love you man, I finally did it! Two addEventListeniner isn’t wise apparently, but a simple if statement cures everything. Nice advice with the hover one as well. Thank you very much, it’s my first project since months back, and finishing it is so satisying!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.