fonol / anki-search-inside-add-card

An add-on providing full-text-search and PDF reading functionality to Anki's Add card dialog
https://ankiweb.net/shared/info/1781298089
GNU Affero General Public License v3.0
177 stars 24 forks source link

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

Open kvn1351 opened 2 years ago

kvn1351 commented 2 years ago

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

fonol commented 2 years ago

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

kvn1351 commented 2 years ago
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.