I am seeing a bug with all scripts disabled where the WanaKana library’s unbind() method is being called even in cases where it is not bound to the answer textbox, such as after a meaning item is answered. This results in a warning being logged to the console.
Another big annoyance (bug?) with WanaKana is that the cursor always moves to the end of the text whenever a mora is converted. So if I type う, then move my cursor to before う and type ちが, then instead of getting ちがう like I would expect, I get ちうが.
Edit: It seems like you may have recently changed something that makes the second bug harder to trigger, but it can still be triggered by following the instructions here and at least one other person has confirmed this. Even though the bug happens less often now, the cursor flickering to the end is still annoying, so it would be nice if it is fixed.
Edit 2: I did some checking, and it looks like it is possible to change the value of a text input and simultaneously update the cursor position without any race condition and without the cursor flashing to the end.
Edit 3: I think I found the code that is causing this bug:
// WanaKana/blob/master/src/utils/dom.js
// line 42
if (tail.length) {
// push later on event loop (otherwise mid-text insertion can be 1 char too far to the right)
setTimeout(() => target.setSelectionRange(newCursor, newCursor), 1);
I think if you made this call synchronous and robustly fixed the root cause of the off by 1 insertion error (instead of using the setTimeout hack), this would fix the issue.
I just checked again and it’s harder for me to reproduce now than it used to be but I can still reproduce the issue as follows. (Maybe they changed something recently?)
type ああ
move the cursor between the two あ’s.
repeatedly mash on the keyboard very quickly
a small amount of the text will be after the second あ.
It used to be the text was always at the end, but now it seems like they try to relocate the cursor but whatever they are doing has a race condition.
It’s easier to reproduce if you open up developer tools, go to performance, click the gear icon, and select throttling → 6x slowdown. Also, the way you mash the keys affects reproducibility too. I find best results by placing both hands on the home row in the standard typing position and then simultaneously pressing and releasing all keys in the home with both hands as fast as possible repeatedly for 5 full seconds.
Same, caret flickers, sometimes it’s annoying
however when trying to reproduce on purpose it takes real key smashing for letters to teleport to the end
When you type a mora in romaji, they update the text in the answer prompt to replace the romaji with the hiragana. Doing this causes the cursor to be sent to the end. They then move the cursor back to where it is supposed to be, but for some reason, instead of doing this immediately, it appears that they wait. This small period of time where the cursor is at the end appears to be what is causing the issue. If they moved the cursor immediately after updating the input, I believe this would solve the problems of both the cursor flashing to the end and the possibility of text getting entered at the end instead of the middle.
You might be able to increase the chance of getting a response to your issue by starting a new thread and tagging the mods, since this current thread is about bugs related to WanaKana (WaniKani’s IME).
Thanks. Another unrelated minor issue I am seeing is that on the lessons page, if you type something that makes the answer bar shake, a horizontal scroll bar will appear and then flicker at the bottom of the page. (Tested with all scripts disabled.)