anki-search-inside-add-card icon indicating copy to clipboard operation
anki-search-inside-add-card copied to clipboard

Can't select/highlight text after clicking on an Anki field

Open kvn1351 opened this issue 2 years ago • 2 comments

Describe the bug As soon as an Anki field is selected (active and blue as in the screenshot), I can't select any text in the pdf reader anymore. I have to enter some other field like the tag field or page field (lower right) to deselect the Anki field. Only at that point, I'm able to select/highlight again.

To Reproduce

  1. Open a pdf
  2. Select some Anki field
  3. Try to select some text in the pdf viewer. It doesn't work.

Expected behavior I expect to be able to add some text to an Anki field without making the pdf portion nonselectable.

Screenshots image

Environment: macOS Monterey Version 12.4 (21F79)

Version ⁨2.1.53 (96bacf79)⁩ Python 3.9.7 Qt 6.3.0 PyQt 6.3.0

Addon version: latest Anki web download as of today.

Enabled Addons: Only this one is enabled

kvn1351 avatar Jun 23 '22 22:06 kvn1351

Thanks for the report, I can confirm it. Works in 2.1.52, breaks in 2.1.53. No idea what's causing it. I wrote an issue in the official Anki forums, there are some active devs there, maybe someone has an idea.

https://forums.ankiweb.net/t/editor-focus-handling-in-2-1-53/20983

fonol avatar Jun 24 '22 06:06 fonol

let siacView = document.getElementById('siac-right-side');

siacView.addEventListener('mousedown', function() {
    // one solution would be to have a hidden field for this sole purpose
    let someNonAnkiField = document.getElementById('siac-pdf-page-inp');
    someNonAnkiField.focus();
    someNonAnkiField.blur();
}, false);

This is a hacky and unelegant workaround but it works 100% without any unintended behavior. I'm so annoyed at their onBlur trap. They could have done it very differently with regards for addons in my humble opinion.

Also, I'd use a hidden field instead though, for this sole purpose.

kvn1351 avatar Jun 24 '22 13:06 kvn1351