Prevent loosing focus on select in autocomplete

UI Components for Angular
Post Reply
mconner
Posts: 3
Joined: 09 Nov 2017, 16:35

29 Oct 2019, 16:38

I've got a p-table with a column that allows for editing a path:

Code: Select all

            <td  pEditableColumn>
                <p-cellEditor>
                    <ng-template pTemplate="input">
                        <p-autoComplete  #pathAutoComplete [(ngModel)]="asHost(row).path"
                                         [suggestions]="fileResults"
                                         (completeMethod)="fileSearch($event)"
                                         (onSelect)="valueSelected($event, pathAutoComplete)"
                                         (onKeyUp)="onKeyUp($event)"
                                         (onBlur)="onBlur($event)"
                        ></p-autoComplete>
                    </ng-template>
                    <ng-template pTemplate="output">
                        {{asHost(row).path}}
                    </ng-template>
                </p-cellEditor>
            </td>

As the user types, i want to show them possible completions, but if they select one, to allow them to continue typing, until they hit tab. Right now, as soon as they select a suggestion, the editing completes, and because its an editable column, the autocomplete effectively is gone.
Is there a way to prevent the selection from causing p-autoComplete to loose focus?
BTW: when a suggestion is selected, the onBlur() is never called, nor even the onKeyUp (for Enter), and the onSelect doesn't have an event, just the selected value, so there's no way to do an event.preventDefault().

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests