Blog create chip Enter/Space + removed double-calls removeEmbeddedLink #1107

Closed
opened 2026-08-13 14:44:36 +00:00 by spikerj · 1 comment
Owner

blog-create.html binds three remove paths on each embedded-link chip:

<mat-chip-option
  (removed)="removeEmbeddedLink(i)"
  (keydown.enter)="removeEmbeddedLink(i)"
  (keydown.space)="removeEmbeddedLink(i)"
>
  <button matChipRemove ...></button>
</mat-chip-option>

i is captured from @for. Material's chip often emits removed after Enter/Space (and matChipRemove also emits removed). The second call uses the same index against the already-mutated array, so the next link is deleted too.

Repro: two chips; press Enter on the first → both URLs gone if removed also fires.

Fix: keep a single handler ((removed) only, or keyboard handlers that preventDefault/stopPropagation and do not also bind removed).

`blog-create.html` binds three remove paths on each embedded-link chip: ```html <mat-chip-option (removed)="removeEmbeddedLink(i)" (keydown.enter)="removeEmbeddedLink(i)" (keydown.space)="removeEmbeddedLink(i)" > <button matChipRemove ...></button> </mat-chip-option> ``` `i` is captured from `@for`. Material's chip often emits `removed` after Enter/Space (and `matChipRemove` also emits `removed`). The second call uses the same index against the already-mutated array, so the *next* link is deleted too. Repro: two chips; press Enter on the first → both URLs gone if `removed` also fires. Fix: keep a single handler (`(removed)` only, or keyboard handlers that `preventDefault`/`stopPropagation` and do not also bind `removed`).
Author
Owner

Resolved in spikersoft-angular PR #818 (merged to master). Embedded-link chips use only (removed), so Enter/Space no longer double-deletes the next link. Closing.

Resolved in spikersoft-angular [PR #818](https://git.spikersoft.com/spikerj/spikersoft-angular/pulls/818) (merged to `master`). Embedded-link chips use only `(removed)`, so Enter/Space no longer double-deletes the next link. Closing.
Sign in to join this conversation.