EditorField instances not ordered according to DOM tree once new fields are mounted
- Dominant language
- Rust
- Stars
- 30.5k
- Forks
- 3.2k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 72
Description
https://github.com/ankitects/anki/blob/50e36bc312b64c59fcd53c283596daeeaba9521e/ts/sveltelib/lifecycle-hooks.ts#L41-L42
Mounting new fields (e.g. when switching from Basic to Basic + reverse card) shifts the initial fields to the end of `EditorField.instances`:



Developers will assume the instances are ordered according to their appearance in the DOM tree, so we should handle the case where instances is already filled with something like:
```
instances = oldInstances.concat(newInstances);
```
The `setup` function of `lifecycleHooks` seems to be oblivious to the bigger picture (in this case, the difference between mounting fields when loading the first note and appending new fields when switching to another note). Any ideas?
Contributor guide
Research direction
Read ts/sveltelib/lifecycle-hooks.ts around lines 41-42, then reproduce the case where switching from Basic to Basic + reverse card mounts new fields. The change is done when EditorField.instances remains ordered according to the fields' appearance in the DOM after new fields are mounted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100