Skip to content

[New Study Screen] When using type to answer cards refeshes when using js to alter card contents. #20127

@nico-lechatnoir

Description

@nico-lechatnoir

Checked for duplicates?

  • This issue is not a duplicate

Does it also happen in the desktop version?

  • This bug does not occur in the latest version of Anki Desktop

What are the steps to reproduce this bug?

When using the new study screen I uses a stylized <a> that triggers a js function that finds the length of a field and changes the inner text. On second tap it reveals a second field and hides the first by changing the style display settings. Example below:

<a id="firstHint" class="hint" href="#" onclick="getNum()"># Char(s)</a>
<div id="hintPinyin" class="hint" style="display: none">{{Pinyin}}</div>

<span lang="zh-cmn-Hans-CN">{{type:Simplified}}</span>
<script>
function getNum() {
	// Create a 2 step hint showing length of words before Hanzi
	const clue = document.getElementById('firstHint');
	if (clue.innerText.startsWith('#')) {
		const simp = document.getElementById('simplified').textContent.trim().length;
		clue.innerText = clue.innerText.replace('#', simp);
		const re = /\((s)\)/g;
		clue.innerText = (simp > 1) ? clue.innerText.replace(re, '$1') : clue.innerText.replace(re, '');
	} else {
		clue.style.display = 'none';
		document.getElementById('hintPinyin').style.display = 'inline';
	}
}
</script>
  1. Tapping the first <a> the first step of the function triggers
  2. The card is then reloaded and reverts to the original text
  3. Any text in the type to answer field is also cleared

This only happens when type to answer is in the card. Cards without function properly and do not refresh. This works correctly on the old reviewer, desktop, and iOS

Expected behaviour

  1. Tapping the link should reveal the length of the Simplified field
  2. Tapping again reveals the Pinyin field and hides the link

Image
Image
Image

Debug info

AnkiDroid Version = 2.23.3 (9001068fd4819c6fb66cb8239e7166868ab47859)  
Backend Version = 0.1.62-anki25.09.2 (25.09.2 3890e12c9e48c028c3f12aa58cb64bd9f8895e30)  
Android Version = 16 (SDK 36)  
ProductFlavor = play  
Device Info = samsung | samsung | dm1q | dm1qcsx | SM-S911W | qcom  
Webview User Agent = Mozilla/5.0 (Linux; Android 16; SM-S911W Build/BP2A.250605.031.A3; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/143.0.7499.192 Mobile Safari/537.36  
ACRA UUID = f85fc69e-888b-4391-b92d-cd15f1283311  
FSRS = 5.1.0 (Enabled: true)  
Crash Reports Enabled = true

(Optional) Anything else you want to share?

No response

Research

  • I have checked the manual and the FAQ and could not find a solution to my issue
  • (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions