# Yomichan not closing popover in forums

**URL:** <https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961>\
**Category:** Bugs & Errors\
**Created:** [January 6, 2018, 3:40pm UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961 "2018-01-06T15:40:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanblue](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/seanblue/32/579844_2.png) [@seanblue](https://community.wanikani.com/u/seanblue)\
**Post date:** [January 6, 2018, 3:40pm UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/1 "2018-01-06T15:40:30Z")

</div>

It might seem odd that I’m posting a bug with Yomichan on the WaniKani forums, but this bug only happens on these forums. When you use Yomichan to lookup a Japanese word on the page, it shows a little popover (image below). Normally clicking out of the box closes the popover, but this does not work on the WaniKani forums.

Additionally, the bug doesn’t even happen on other discourse forums, such as [https://discourse.mozilla.org](https://discourse.mozilla.org). I tested there by typing the japanese text in the search box and the issue does not occur (doing it this way **does** cause the bug on the WK forums too, just like using it in a forum post).

I believe this has been happening for less than a month, so maybe the WK team updated the forums recently or changed some configuration.

* * *

**Using Yomichan**  
 ![image](https://global.discourse-cdn.com/wanikanicommunity/original/3X/c/4/c4c209ff41478cd7986c28de4c7edb4aa03f5f6c.png)

* * *

**After clicking away it should close but doesn’t**  
 ![image](https://global.discourse-cdn.com/wanikanicommunity/original/3X/2/5/25424c2c9298ccf0eb1e2e3b9fc10b296cc18aa0.png)

---

<div class="post-metadata">

**Author:** ![temporaryuser381](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/temporaryuser381/32/151314_2.png) [@temporaryuser381](https://community.wanikani.com/u/temporaryuser381)\
**Post date:** [January 6, 2018, 3:52pm UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/2 "2018-01-06T15:52:28Z")

</div>

great, now mine is stuck too. 😫

BTW I would suggest using RikaiChamp too. It is a good alternative to YomiChan.

---

<div class="post-metadata">

**Author:** ![SleepyOne](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/sleepyone/32/217940_2.png) [@SleepyOne](https://community.wanikani.com/u/SleepyOne)\
**Post date:** [January 6, 2018, 11:14pm UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/3 "2018-01-06T23:14:10Z")

</div>

I’ve been experiencing the same thing for the past week or two now. Quite annoying, and I haven’t been able to recreate it anywhere else either.

---

<div class="post-metadata">

**Author:** ![seanblue](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/seanblue/32/579844_2.png) [@seanblue](https://community.wanikani.com/u/seanblue)\
**Post date:** [January 6, 2018, 11:36pm UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/4 "2018-01-06T23:36:51Z")

</div>

At least I’m not the only one. I’ll ping Viet on Monday during work hours if nobody from WK has responded by then.

---

<div class="post-metadata">

**Author:** ![mdboop](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/mdboop/32/77560_2.png) [@mdboop](https://community.wanikani.com/u/mdboop)\
**Post date:** [January 6, 2018, 11:39pm UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/5 "2018-01-06T23:39:02Z")

</div>

If you click inside the popover, then hit `esc`, it will disappear. Still very annoying.

---

<div class="post-metadata">

**Author:** ![mdboop](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/mdboop/32/77560_2.png) [@mdboop](https://community.wanikani.com/u/mdboop)\
**Post date:** [January 7, 2018, 12:00am UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/6 "2018-01-07T00:00:04Z")

</div>

Hmm, it’s unclear if the bug is in the WK or Yomichan (I’ve experienced this behavior on other sites), but after some debugging, I can see there’s an event listener that’s being attached but never called. Some other event listeners are working, which is weird. Like if you resize the window, the popover disappears. And the `mousemove` listener is working, but not correctly (I think). Feeling too lazy to keep digging into this, but if anyone else cares to help, this is a good place to start looking: [yomichan/frontend.js at e5905dd732d4ffd0915ae27cb3b0c84256482443 · FooSoft/yomichan · GitHub](https://github.com/FooSoft/yomichan/blob/e5905dd732d4ffd0915ae27cb3b0c84256482443/ext/fg/js/frontend.js#L36)

edit:

OK, I couldn’t help myself. It does seem like there’s some other js running on the page preventing new listeners from being added…? If I open up the console and enter `window.addEventListener('mousedown', () => { console.log('woo'); });` and then click around, I don’t see anything. But if you visit any other page and do the same, you’ll see ‘woo’ printed every time you click.

edit2: If you attach the `mousedown` event to `document` instead, it works fine. Pausing the code running, grabbing the handler, saving a reference, then attaching it to document myself fixes the bug. Obviously, that’s not a solution. But, it does raise the question for Yomichan if perhaps using `document` instead for attaching the mouse events.

---

<div class="post-metadata">

**Author:** ![seanblue](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/seanblue/32/579844_2.png) [@seanblue](https://community.wanikani.com/u/seanblue)\
**Post date:** [January 7, 2018, 12:40am UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/7 "2018-01-07T00:40:10Z")

</div>

Do you want to write up a bug with these details on his github page? I would, but between you seeing it on other sites and digging into the code you can provide much more detail than I could. If your suggested change is easy and reasonable, Yomichan might as well handle it. But it also seems like bad practice for websites to prevent new listeners from being added, so I feel like WaniKani/Discourse should fix it on this side too.

---

<div class="post-metadata">

**Author:** ![mdboop](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/mdboop/32/77560_2.png) [@mdboop](https://community.wanikani.com/u/mdboop)\
**Post date:** [January 7, 2018, 12:47am UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/8 "2018-01-07T00:47:09Z")

</div>

Yeah, I’d be happy to. You’re right, though, that there must be something WK-side that should be fixed, too. Hopefully these details will help them narrow it down a bit.

---

<div class="post-metadata">

**Author:** ![viet](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/viet/32/41979_2.png) [@viet](https://community.wanikani.com/u/viet)\
**Post date:** [January 7, 2018, 2:33am UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/9 "2018-01-07T02:33:28Z")

</div>

Thats odd.

I do know we’ve added a couple JS code on top of the default Discourse build, but that was back when we migrated to Discourse.

One thing to note are we are on a hosted platform directly with Discourse. They like to push out the latest builds (beta…) to their hosted boards. They’ve just released their latest version, 1.9. I would review if the boards you are comparing against ours are on the same version. This information is available in the meta tags.

I’ll take a peek at our JS addons and see if there is something…

---

<div class="post-metadata">

**Author:** ![viet](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/viet/32/41979_2.png) [@viet](https://community.wanikani.com/u/viet)\
**Post date:** [January 7, 2018, 2:38am UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/10 "2018-01-07T02:38:07Z")

</div>

There are two JS snippets we include on top of the Discourse build; both don’t alter mouseover events and they are scoped to very specific classes.

---

<div class="post-metadata">

**Author:** ![seanblue](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/seanblue/32/579844_2.png) [@seanblue](https://community.wanikani.com/u/seanblue)\
**Post date:** [January 7, 2018, 3:24am UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/11 "2018-01-07T03:24:40Z")

</div>

**WaniKani forums:**  
Discourse 1.9.0.beta17  
version [38269c416d96b8f0b32bb6fbbce54048f5173a7f](https://github.com/discourse/discourse/commit/38269c416d96b8f0b32bb6fbbce54048f5173a7f)

* * *

**[Mozilla forums](https://discourse.mozilla.org/):**  
Discourse 1.9.0.beta17  
version [7ca2e6a80ce7086895fc1f71bba86ba4e874d16d](https://github.com/discourse/discourse/commit/7ca2e6a80ce7086895fc1f71bba86ba4e874d16d)

* * *

They both say 1.9.0.beta17, but as you can see they are different commits. Mozilla’s version’s commit is from 4 days ago. WaniKani’s version’s commit is from 7 days ago. If this is a discourse bug then perhaps they already fixed the issue and the update just needs to be pushed to these forums. I don’t see any commit messages mentioning anything about this bug though, so who knows.

---

<div class="post-metadata">

**Author:** ![viet](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/viet/32/41979_2.png) [@viet](https://community.wanikani.com/u/viet)\
**Post date:** [January 7, 2018, 3:55am UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/12 "2018-01-07T03:55:19Z")

</div>

Thanks for the info.

One of the JS snippets we include is just an `.on('click')` on a very specific class. The other is an event listener from the Discourse API `api.onPageChange((url, title)`; the action we added is scoped to a specific class (within PMs. We just inject the HTML which displays the PM warning).

Are you by chance running any WK Community specific scripts?

---

<div class="post-metadata">

**Author:** ![viet](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/viet/32/41979_2.png) [@viet](https://community.wanikani.com/u/viet)\
**Post date:** [January 7, 2018, 4:10am UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/13 "2018-01-07T04:10:18Z")

</div>

I’ve installed Yomichan from the Google extension site on Google Chrome 63.0.3239.132 (OS X) with the english JM Dict dictionary imported. Using the shift key and hovering over the text on WK Community I get the popover. Clicking outside the popover or hitting escape (without clicking the popover to focus) exits the popover. Is this the expected behavior?

---

<div class="post-metadata">

**Author:** ![seanblue](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/seanblue/32/579844_2.png) [@seanblue](https://community.wanikani.com/u/seanblue)\
**Post date:** [January 7, 2018, 5:49am UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/14 "2018-01-07T05:49:17Z")

</div>

I am not using any scripts on the forums.

The expected behavior is that clicking outside the popover or pressing escape closes the popover. I think the extension auto-focuses on the popover for escape to work, but that’s probably not relevant.

From what you described it sounds like it’s working for you. I’ll have to try it again tomorrow to see if it’s still reproducible.

---

<div class="post-metadata">

**Author:** ![seanblue](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/seanblue/32/579844_2.png) [@seanblue](https://community.wanikani.com/u/seanblue)\
**Post date:** [January 7, 2018, 4:54pm UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/15 "2018-01-07T16:54:46Z")

</div>

Use to test:  
鰐蟹

@viet If you use Yomichan on the above text and then click out of the popover, does the popover disappear? For me, the popover stays.

---

<div class="post-metadata">

**Author:** ![viet](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/viet/32/41979_2.png) [@viet](https://community.wanikani.com/u/viet)\
**Post date:** [January 7, 2018, 7:30pm UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/16 "2018-01-07T19:30:25Z")

</div>

I was able to replicate it. On all Discourse boards.

The condition is you need to be logged into the boards. Have you logged into the Mozilla boards and tried the Yomichan?

It worked for me before because I wasn’t logged into the forums when I was troubleshooting on Chrome. Logging into an account on here, Mozilla, and [meta.discourse.org](http://meta.discourse.org) all exhibit the issues you described.

Based on this, this isn’t a specific [community.wanikani.com](http://community.wanikani.com) issue; its either Yomichan or Discourse.

---

<div class="post-metadata">

**Author:** ![seanblue](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/seanblue/32/579844_2.png) [@seanblue](https://community.wanikani.com/u/seanblue)\
**Post date:** [January 7, 2018, 7:57pm UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/17 "2018-01-07T19:57:34Z")

</div>

Oh interesting, I was not logged in. I think it’s an overall discourse bug then, because I haven’t had this happen on any other website.

---

<div class="post-metadata">

**Author:** ![viet](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/viet/32/41979_2.png) [@viet](https://community.wanikani.com/u/viet)\
**Post date:** [January 7, 2018, 8:09pm UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/18 "2018-01-07T20:09:51Z")

</div>

I haven’t done much low level troubleshooting, but I did noticed Discourse “Quote” feature appears when using Yomichan while logged in (not present as logged out user). Looks like Yomichan is highlighting the text, which activates Quote. I wonder if there is some conflict between the two?

---

<div class="post-metadata">

**Author:** ![seanblue](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/seanblue/32/579844_2.png) [@seanblue](https://community.wanikani.com/u/seanblue)\
**Post date:** [January 7, 2018, 8:14pm UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/19 "2018-01-07T20:14:56Z")

</div>

Okay. Well I’ve opened an issue on Yomichan’s github for now. Hopefully something can be done on their side. If not, I may have to file an issue with Discourse.

> <https://github.com/FooSoft/yomichan/issues/111>
>
> This is a strange issue, probably due to bad website design. Ideally websites wo…uldn't block the registering of events, but if reasonable Yomichan should still work anyway.
> 
> It seems like this bug occurs on Discourse websites (but only when logged in) and I would assume other websites on occasion, though I haven't encountered any others.
> 
> The issue is that when you have the popover open and click away, it doesn't close. Here was a diagnosis done by someone: https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/6
> 
> According to that poster, theoretically changing \[this line\](https://github.com/FooSoft/yomichan/blob/e5905dd732d4ffd0915ae27cb3b0c84256482443/ext/fg/js/frontend.js#L36) (and I assume others) from \`window\` to \`document\` would fix the issue. Though of course I have no idea if that has other side effects.
> 
> Let me know if you think fixing this is unreasonable and I'll open an issue with Discourse.

---

<div class="post-metadata">

**Author:** ![seanblue](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/seanblue/32/579844_2.png) [@seanblue](https://community.wanikani.com/u/seanblue)\
**Post date:** [January 15, 2018, 11:02pm UTC](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961/20 "2018-01-15T23:02:20Z")

</div>

@viet Should I just open a bug with Discourse at this point?

[Next page](https://community.wanikani.com/t/yomichan-not-closing-popover-in-forums/24961.md?page=2)
