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

**URL:** https://meta.discourse.org/t/clicking-a-widget-with-a-click-hook-doesnt-trigger-clickoutside-on-other-widgets/42150
**Category:** Bug
**Created:** [4월 6, 2016, 10:27오후 UTC](https://meta.discourse.org/t/clicking-a-widget-with-a-click-hook-doesnt-trigger-clickoutside-on-other-widgets/42150 "2016-04-06T22:27:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Nuck](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nuck/32/121732_2.png) [@Nuck](https://meta.discourse.org/u/Nuck)
#### Post date: [4월 6, 2016, 10:27오후 UTC](https://meta.discourse.org/t/clicking-a-widget-with-a-click-hook-doesnt-trigger-clickoutside-on-other-widgets/42150/1 "2016-04-06T22:27:38Z")

</div>

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](https://github.com/discourse/discourse/blob/8f4bc2228fd5def7a4190222b0ae993a384791d9/app/assets/javascripts/discourse/widgets/click-hook.js.es6#L45) 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.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [4월 7, 2016, 8:11오후 UTC](https://meta.discourse.org/t/clicking-a-widget-with-a-click-hook-doesnt-trigger-clickoutside-on-other-widgets/42150/2 "2016-04-07T20:11:14Z")

</div>

Good catch! Here’s a fix:

[https://github.com/discourse/discourse/commit/71ef6ea5185dbe8a68baf599f852b5c652639471](https://github.com/discourse/discourse/commit/71ef6ea5185dbe8a68baf599f852b5c652639471)

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [4월 7, 2016, 8:11오후 UTC](https://meta.discourse.org/t/clicking-a-widget-with-a-click-hook-doesnt-trigger-clickoutside-on-other-widgets/42150/3 "2016-04-07T20:11:19Z")

</div>


