Clicking a Widget with a click() hook doesn't trigger clickOutside() on other widgets

This is kind of a strange technical bug, but clickOutside() doesn’t trigger if the widget you click (outside) has a click() hook.

Reproduction:

  1. Open “Post Admin” menu
  2. Click “Like” or “Link” button
  3. “Post Admin” menu doesn’t disappear

What I Expect:

  1. Open “Post Admin” menu
  2. Click “Like” or “Link” button
  3. “Post Admin” menu disappears

I should add that this “expected” behavior is also the behavior when clicking noninteractive elements outside the menu.

The code is likely this early return in the WidgetClickHook, which will trigger for any widget with a click handler, preventing it from reaching the handling for clickOutside below. This should probably trigger clickOutside on any widgets which aren’t the widget that you triggered click on or its ancestors, instead.

2 Likes

Good catch! Here’s a fix:

https://github.com/discourse/discourse/commit/71ef6ea5185dbe8a68baf599f852b5c652639471

2 Likes