All 35 Bugs /
0/35 Fixed ✓
AngularMedium~12 min

Missing Key / trackBy List Input Focus Loss

What's Broken (Symptom)

Clicking "Prepend Urgent Task" wipes and recreates all `<li>` DOM nodes using `innerHTML`, causing the focused input inside Task A to lose focus and cursor!

Expected Behavior

  • Reconcile rows by stable `item.id` key (`data-key`) instead of calling `list.innerHTML = ""`.
  • Existing DOM `<input>` element references stay mounted in the DOM when prepending a new item.
  • User focus (`document.activeElement`) and typed value on Task A remain intact after prepend.

Debugging Hints (0/2 used)

Try spotting the bug in the editor first. Need a nudge? Reveal Hint 1 anytime.

Root Cause Breakdown

Pass all 3 automated verification checks on the right to unlock the full Root Cause explanation.

Automated Bug Verification

3 Checks Ready
  • Reuses the exact <input> DOM node across prependSame input node reference for t-1 stays mounted after prepending t-0.
  • Keeps input focus and typed draft value on Task t-1document.activeElement remains focused on t-1.
  • Places new urgent task cleanly at the top of the listFirst child key must be t-0 and total items 3.
bugfix.html
Live Sandboxed PreviewCtrl + Enter to verify
Console Output0 log(s)
No console output yet. Run Preview or Verify Bug Fix.