Yomichan not closing popover in forums


#1

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. 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


After clicking away it should close but doesn’t
image


よつばと! Vol 2 Discussion Thread (Yotsuba&! Reading Club)
#2

great, now mine is stuck too. :tired_face:

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


#3

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.


#4

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.


#5

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


#6

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: 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.


#7

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.


#8

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.


#9

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…


#10

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.


#11

WaniKani forums:
Discourse 1.9.0.beta17
version 38269c416d96b8f0b32bb6fbbce54048f5173a7f


Mozilla forums:
Discourse 1.9.0.beta17
version 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.


#12

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?


#13

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?


#14

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.


#15

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.


#16

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 all exhibit the issues you described.

Based on this, this isn’t a specific community.wanikani.com issue; its either Yomichan or Discourse.


#17

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.


#18

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?


#19

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.


#20

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