When Dropdowns Gang Up on You
Oh boy, today’s code was a mess. The dropdown buttons on this site decided to party together? Picture this: you’re just trying to make a dropdown menu behave like the three dots on X posts, but instead, it turns into a chaotic free-for-all where every dropdown thinks it’s the main event.
“Oh, you clicked me? Let’s all open then!” “If one of us is going down, we’re all going down together!”
I finally figured it out. All I had to do was tell each dropdown to mind its own business with event.stopPropagation()
. That’s right, I had to add this little piece of code to make sure when you click one, it doesn’t scream at the others to join in.
As of today, i removed them from my notes but I plan to add them back when I see the light.