Merl's Blog

Clicking

I encountered when creating a new story and trying to add members right after. This bug was particularly tricky because it only appeared under specific conditions.

Bug

When a new story was created, if I immediately tried to add a member and then clicked away from the panel, the member wouldn’t be saved to the story. In any other situation, adding the member worked perfectly, but this one case was causing issues.

I started digging into why this was happening. Initially, everything looked fine—buttons were there, and the usual process seemed to work. But after some time I noticed something.

When a story is first created, there are a few initial buttons. However, once the story finishes creating, a new button appears, shifting everything else down. That seemed interesting.

Logic

It was because toggling the member was tied to a mouse click event.

When the new button appeared, the layout shifted, causing the click event not to register properly since it didn’t happen at the same position.

The Fix

To fix this, I changed the event from :on-click to :mouse-down. This ensured that the member addition would register correctly, even with the layout shift.

Here’s the code change that fixed the issue:

;; Before
{:on-click #(toggle-user! user current new? frozen?)}

;; After
{:mouse-down #(toggle-user! user current new? frozen?)}

Now the members saved in all situations.

It is interesting how a small UI changes can have unexpected effects.

By playing around with the functionality and then looking at the code I was able to finally find the solution.

Best,

Merl