The project uses Angular 20.0.x with a standalone component, TypeScript 5.8.x, RxJS 7.8.x, HttpClient via provideHttpClient(), changeDetection: ChangeDetectionStrategy.OnPush, and the default zoned mode (Zone.js enabled). The component opens a profile card by a string identifier and shows one of three states: loading, data, or an error message. The request is performed with GET /api/profiles/:id and returns JSON of the form { "id": string, "name": string, "city": string }; for a missing profile the server responds with 404. Reproduction: 1) open the component; 2) enter the existing id anna and wait for it to load; 3) then quickly start new searches with the button or Enter key, for example maria, then 404; 4) observe the panel state while switching and after the error. Expected product behavior: while a new request is in progress, the loading indicator must not disappear too early; after an unsuccessful new request, data from the previous successful profile must not remain on screen; the search button must be unavailable for an empty string or a string containing only spaces. In the PR below, this behavior regressed. Find and describe the causes.
Node.js 22.x, Angular CLI 20.0.x, Angular 20 standalone API, RxJS 7.8.x, TypeScript 5.8.x. The application runs in the browser, without SSR. FormsModule with [(ngModel)] is used for the form. HTTP requests are considered cancellable via unsubscribe on the HttpClient observable.
Use line comments to explain the problem, its impact, the fix and how to test it.