ankitects / ankitects/anki

Async callback on EditorField lifecycle hook causes error when switching to notetype with fewer fields

Ouverte
#1,959 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
editor
Langage dominant
Rust
Étoiles
30.5k
Forks
3.2k
Merge moyen
2 j 8 h
PR mergées (30 j)
60

Description

While debugging https://github.com/hgiesel/closet/issues/96 I noticed the following error message when switching notetypes in the browser:

```
Uncaught (in promise) TypeError: cleanup is not a function
at browser_editor.js:33322
at run (browser_editor.js:30587)
at Array.forEach ()
at run_all (browser_editor.js:30593)
at destroy_component (browser_editor.js:32224)
at Object.d (browser_editor.js:78807)
at browser_editor.js:31587
at run (browser_editor.js:30587)
at Array.forEach ()
at run_all (browser_editor.js:30593)
```

This is the relevant function:
https://github.com/ankitects/anki/blob/50e36bc312b64c59fcd53c283596daeeaba9521e/ts/sveltelib/lifecycle-hooks.ts#L29-L49

## Reproduction steps
1. Add async callback to EditorField (e.g. with `webview_will_set_content` hook):
`require("anki/EditorField").lifecycle.onMount(async () => console.log("mounted")); `
2. switch to a notetype with fewer fields to cause a `cleanup()` call

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.