Behavior when not typing anything in

  • Hide the typing comparison if the user hits enter without typing anything.

Just emitting the field in a naked div breaks existing CSS rules.

Now that I remember, I already did this 2.5 years ago like this here. So just changing it to…

output = "<code id=typeans>" + expected + "</code>"

… works.

1 Like

I am not really sure how and when translations are added to new Anki releases; in any case, I made a few important edits in the last couple of days and they do not seem to be in this RC yet


Edit:

This feature is great, but there seems to be a bug regarding images.
Steps to reproduce:

  • add some text and 1 or more images to the type field (as in {{type:TypeField}})
  • study the card. Do not type anything and flip it
    → the “type field section” on the back of the card will not just show the text you were supposed to type, but also the image(s).
    It seems this cannot be prevented by using {{type:text:FieldName}}.

Also: maybe it would be better to still include the TypeMissed class (or some other class) or at least the gray background, even if you did not type anything?
In the example below using the Basic (type in the answer) note type, it is not immediately evident that one of the two “hello” is a type field, it kind of looks like the answer field is shown twice for no good reason. I suspect this will cause confusion to many users.

@nwwt My thinking here is that as the user has not typed anything in, it does not make sense to show the answer styled as if it’s a comparison, so it’s not wrapped in a typeans section. Styling that targets the typeans section and makes assumptions about how many children it has will thus not run, and should not break. How is your styling breaking?

@jcznk The default type-in-the-answer template does not include {{Back}} on the template, so text shouldn’t be duplicated unless the template has been customized. Putting images in a field that you’re typing in is not advisable, since you end up having the text repeated when you add another copy of the field to the template to get the image to display. If the image were placed in a separate field instead, the problem is avoided.

We could potentially strip the images/audio from the no-input case to make it consistent with the input case.

Translations were last synced shortly before rc1 was built; if you made changes since then, I’m afraid it will need to wait until the next beta.

Previously, an author could use rules like code#typeans for unified styling & without further template changes regardless of whether the individual user was using the type functionality:

That’s gone now for Anki Desktop (& presumably Mobile), leaving such decks defective (seriously so, given {{type}} is commonly used for the main content). So if the author is still around, they’re left explain the necessary changes (yet to make) to each existing user individually.

AnkiDroid, on the other hand, continues doing the IMO sensible thing, which is simply omitting the <br>s & span#typearrow elements when nothing is typed. So the current change adds an unnecessary styling incompatibility, rather than reducing one. A larger one at that, given it can’t just be worked around nightMode night_mode-style.

Oh, my bad, I remembered wrongly what the default template was.

Uniforming the input and no-input cases seems like a good idea.

Another thing: I am having difficulties stylizing the font-family and font-size of the type field on the back of the card, in the no-input case. It seems like those two styles are defined inline and cannot be easily overridden?
Maybe I am doing something wrong.
What I tried was: employing :root and html in the CSS to change the size of all fonts; wrapping the type field in a div with a class e.g. <div class="foo">{{type:fieldName}}</div> and then using this class as a selector .foo {font-size: 25px !important;}, but nothing seemed to work.

Thank you both for elaborating. @nwwt would you like to submit a PR that makes Anki behave as you expect?

I just ran across this too. The styling on my custom template used to work fine if I didn’t type the answer until version 2.1.57. Now the styling doesn’t seem to get applied if I don’t type the answer? What needs to be done to simply make the styling consistent?

The easiest option would be to wait for @nwwt’s proposed changes to land in the next update.

1 Like

Thanks! Sounds good. Appreciate your work.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.