Preserve input state when tracked records reorder.

Preserve input state when tracked records reorder with a standalone Angular component and explicit browser behavior.

TypeScript main.ts
import { Component, signal, input } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';

@Component({
    selector: 'app-root',
    standalone: true,
    template: `
        <main data-ready>
            <button (click)="reverse()">Reverse</button>@for (person of people(); track person.id) { <label>{{ person.name }}<input [value]="person.name" /></label> }
        </main>
    `
})
class App {
    people = signal([{id: 1, name: "Ada"}, {id: 2, name: "Grace"}]);
    reverse() { this.people.update(items => [...items].reverse()); }
}

bootstrapApplication(App).catch(console.error);

Expected output EXAMPLE

Enter “Edited” into the “Ada” control.
Click the button.
The “Ada” control contains “Edited”.

Details

Use this main.ts in a modern Angular 22 standalone project with an <app-root></app-root> element in index.html. It includes bootstrapApplication. The test uses Angular ahead-of-time compilation with strict template checks, then checks the rendered behavior in Chromium.

✓ Verified

Tested on Ubuntu 24.04.3 LTS · · Node.js v24.15.0; Chromium 141.0.7390.37 · @angular/common 22.2.3; @angular/compiler 22.2.3; @angular/core 22.2.3; @angular/forms 22.2.3; @angular/platform-browser 22.2.3; esbuild 0.28.2; playwright 1.56.0; rxjs 7.8.2; @angular/compiler-cli 22.2.3; typescript 6.0.3

Test inputs, results and environment

The exact published code ran in a dedicated Linux test container with prepared inputs. Dedicated test container, external networking disabled, read-only root, temporary per-example working directory. Browser network requests are blocked. Fixtures and output records are isolated from the application database. Testing covers this example and its stated checks, not every input, operating system, or runtime version. The Linux container shares its host's kernel; this is not a native Windows test.

Architecture / host kernel
x86_64 / 6.18.54.1-microsoft-standard-WSL2
Snippet identity / locale
uid=65534, gid=65534 (unprivileged) / C.UTF-8
Interpreter invocation
Compile with Angular ngc (strict TypeScript and strictTemplates); bundle the exact published component with esbuild; mount it in Chromium and execute browser assertions
Container image ID
sha256:c9bce90110f636fe04907469a37e9c8ac888171fd569cbf87101743ec7cdf099
Code SHA-256
0d0327e383647bd3bbd4a32b21bf2a77a2147d86be7a0bb22b2174d68ae629dd
Dependencies
@angular/common 22.2.3; @angular/compiler 22.2.3; @angular/core 22.2.3; @angular/forms 22.2.3; @angular/platform-browser 22.2.3; esbuild 0.28.2; playwright 1.56.0; rxjs 7.8.2; @angular/compiler-cli 22.2.3; typescript 6.0.3

Test input setup

These are the prepared inputs used by the test harness. See Details above for the prerequisites and how to run this example.

The harness supplies index.html and mounts the published component with locally installed, pinned dependencies.

Observed standard output

Expected output describes the rendered page. The standard-output record below is the browser test harness receipt; the additional assertions check the result and interactions.

Preserve input state when tracked records reorder: browser checks passed.

Exit code: 0. Standard error: empty. Validation: Shape/content assertions. System-dependent values above are one recorded run.

Additional assertions that passed

Checks recorded by the test harness. Where Python assertions are shown, browser cases use Playwright and simulator cases may inspect pin transitions: result.stdout is captured output, work is the temporary directory, and Path is pathlib.Path. The harness also imports json and csv.

await page.getByLabel('Ada').fill('Edited'); await page.getByRole('button').click(); assert.equal(await page.getByLabel('Ada').inputValue(),'Edited');