Any clues on how to disable an option of removing an item from the autocomplete multiple component (https://www.primefaces.org/primeng/showcase/#/autocomplete), I want to avoid removing an item (which contains a field i.e. remove:false) after the user hit the backspace button or click on x icon.
For example, if you choose 'Afghanistan' you shouldn't be able to remove it.
I tried as below but without success: https://stackblitz.com/edit/primeng-autocomplete-demo-tdoe5g?file=src/app/app.component.ts
html:
<p-autoComplete (onUnselect)="avoidRemoval($event); false"
...
/>
ts:
avoidRemoval(event){
if(!event.remove){
event.preventDefault() //event.preventDefault is not a function
}
}
// nothing is happening here
@HostListener("document:keyup", ["$event"])
handleKeyup(event: KeyboardEvent) {
if (event.keyCode === 8) {
event.preventDefault();
//event.stopPropagation();
//return false;
}
}