Skip to content

Conversation

beyondcompute
Copy link
Contributor

@beyondcompute beyondcompute commented Mar 6, 2025

Currently if a user drags slightly (happens to me often unintentionally) upon clicking an audio play button or a hint link, the action does not happen.

Some videos that demonstrate the issue below.

I first click the button successfully but then twice I click it with dragging slightly after mousedown (this video also contains an audio track):

Screen.Recording.2025-03-07.at.01.04.09.mov

An example with a hint link:

Screen.Recording.2025-03-09.at.21.00.31.mov

After the attempted fix:

Screen.Recording.2025-03-10.at.23.10.05.mov
hint_inspection

Hopefully that will be good from the accessibility standpoint.

Thank you!

@beyondcompute beyondcompute changed the title Prevent accidental dragging of audio playback button which cancels playback Prevent accidental dragging of audio playback button and links Mar 9, 2025
@beyondcompute beyondcompute changed the title Prevent accidental dragging of audio playback button and links Prevent accidental dragging of audio playback buttons and various links Mar 9, 2025
@dae
Copy link
Member

dae commented Mar 10, 2025

I'm afraid I'm not sure this is safe - there may be card templates out there using link elements and a 'drag to the correct place' setup that this may break, such as https://old.reddit.com/r/Anki/comments/1f8buan/interactive_anki_flashcard_template_with_drag_and/

@beyondcompute beyondcompute changed the title Prevent accidental dragging of audio playback buttons and various links Prevent accidental dragging of audio playback buttons Mar 10, 2025
Because currently if a user drags slightly (even unintentionally) upon clicking a play button, play does not happen
@beyondcompute
Copy link
Contributor Author

beyondcompute commented Mar 10, 2025

@dae Thank you for the review! 🙏

Would setting draggable="false" at least for audio playback buttons and hint links be acceptable? (Also I could revert the hint links part and keep only the audio button fix.)

Because if a user moves cursor a little after `mousedown`, action (expanding the hint) does not occur. Which might cause issues from accessibility standpoint
@beyondcompute beyondcompute changed the title Prevent accidental dragging of audio playback buttons Prevent accidental dragging of audio playback buttons and hint links Mar 10, 2025
@beyondcompute
Copy link
Contributor Author

@dae I’ve modified the PR, please let me know if that would be acceptable. 😊

Also, could I ask a question about writing an addon (please ignore if you don’t have time, etc.)? Is it possible these days to inject own HTML while rendering a template? I would just like to wrap {{Word}} from the deck’s template into a custom <span> element or something like that.

I saw, card_will_render hook was removed here. And now there is the field_filter but that only seems to be called for custom filters. Is it possible to modify the rendering otherwise or is that against Anki’s philosophy and we are encouraged to modify deck’s templates instead?

Thank you! ⭐

@dae
Copy link
Member

dae commented Mar 14, 2025

I think that's a good compromise, and much less likely to break things - thank you!

I think the comments at the top of https://github.com/ankitects/anki-addons/blob/main/demos/field_filter/__init__.py may address your question about field_filter.

@dae dae merged commit 339bf43 into ankitects:main Mar 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants