-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocomplete empty text when lost focus #8740
Comments
Same problem here. |
The problem appeared in 9.0.1 version. |
Same thing here...Any tips or workarounds? 9.0.6 still has the bug. I've just noticed that this willl only happen when the forceSelection property is set to true (which on my case is required to ensure the proper selection of an existing item on the list). |
Yes, only with forceSelection this happens. Please, take a look at this. With this bug we cannot use autocomplete via keyboard. Atributte forceSelection is mandatory for us, because selected item is not atomic, but object. |
I have same problem, cant go back on version 9.0.0. I use improved p-Dialog. |
Noticed the same problem. As some have already mentioned, this happens since v9.0.1 when you set The problem still exists in the current v9.1.0. What happens internally in the component is this: After the overlay with the suggestions is closed, Does anybody see a reason why the suggestion list is deleted internally in these two places? My naive fix would be to simply never delete it. |
Having the same problem in v9.1.0. And I confirm it was introduced by fixing #8511. But I need this fix as well, so I can't switch back to v9.0.0. I have 'autocomplete' component inside html form and I use the following 'autocomplete' settings:
And then I do following steps:
But it behaves differently with the steps:
@Cito - at first glance, it seems like the problem with I also don't know exact reason to set @Cito - What to you think if we could come up with solution for it and create PR to fix it? I was thinking as well about 'never set Also would be nice to here someone from primeng team, what's their thoughts etc... |
@MaKCbIMKo Before trying to create a fix, we need proper testing, so I have started with that. Below I posted a unit test function that should replace the currently existing test function for I can confirm that this improved test detects the problem in this issue and that my naive fix satisfies the test and does not break any other tests. The question remains whether there is a reason why it('should properly implement forceSelection', fakeAsync(() => {
autocomplete.forceSelection = true;
fixture.detectChanges();
const inputEl = fixture.debugElement.query(By.css('.ui-inputtext.ui-widget'));
inputEl.nativeElement.dispatchEvent(new Event('focus'));
inputEl.nativeElement.focus();
inputEl.nativeElement.click();
flush();
fixture.detectChanges();
// enter valid value
inputEl.nativeElement.value = 'VW';
inputEl.nativeElement.dispatchEvent(new Event('input'));
tick(autocomplete.delay); // wait for debouncing
fixture.detectChanges();
tick(250); // wait for animation showing overlay
fixture.detectChanges();
inputEl.nativeElement.dispatchEvent(new Event('change'));
flush();
fixture.detectChanges();
// value should be kept
expect(inputEl.nativeElement.value).toEqual("VW");
// enter invalid value
inputEl.nativeElement.value = 'vsa';
inputEl.nativeElement.dispatchEvent(new Event('input'));
tick(autocomplete.delay); // wait for debouncing
fixture.detectChanges();
tick(250); // wait for animation showing overlay
fixture.detectChanges();
inputEl.nativeElement.dispatchEvent(new Event('change'));
flush();
fixture.detectChanges();
// value should be removed
expect(inputEl.nativeElement.value).toEqual('');
// enter valid value
inputEl.nativeElement.value = 'VW';
inputEl.nativeElement.dispatchEvent(new Event('input'));
tick(autocomplete.delay); // wait for debouncing
fixture.detectChanges();
tick(250); // wait for animation showing overlay
fixture.detectChanges();
autocomplete.onKeydown({which: 27, preventDefault(){}}); // press escape
fixture.detectChanges();
tick(250); // wait for animation hiding overlay
fixture.detectChanges();
inputEl.nativeElement.dispatchEvent(new Event('change'));
flush();
fixture.detectChanges();
// value should still be kept
expect(inputEl.nativeElement.value).toEqual("VW");
})); |
This is situation from #8511 before this bad fix. If you type "fra" and tab, string will stay in input, if you type "fra" slowly when suggestions are displayed and tab, input will be null. There must be test, which detects situation on blur/change (only when forceSelection enabled):
|
Confirming I have the same problem. With an autocomplete set to [forceSelection]="true", here is the behavior:
The last step clears the selection Note that the following works:
The above steps DON'T clear the selection |
I'm having the same issue, we can't use autocomplete with this bug so we're stuck in version 9.0.0, but also facing the need to update to version 10+ because of the changes in virtual scrolling table. It's weird that new versions are coming along but the bug is not being fixed. I suspect that this is something bigger and not a minor fix. |
I have the same problem. It's still present in version 10.0.0-rc.4. |
any update on this ? |
I have exactly the same issue with prime-ng v10.0.0 |
For what it's worth, I'm using this override which seems to work with no ill effects that I've seen:
|
Thanks for the suggestion. It actually works! Waiting for an upstream fix... |
I have the same issue. Instead of overriding
|
The same on version 11.0.0-rc.1 |
Now wonder, since it has been fixed in 11.0.0-rc.2 only. |
Unfortunately, my tests to avoid regression (see above) have not been added. |
If i have an object in ngModel with properties, where one property is declarated in field, if search and select with enter value from items list then when lost focus text in autocomplete will become empty. But if i select from items list with mouse click text will remain after lost focus. This issue not appear in PrimeNg version 9.0.0.
PrimeNg version : 9.0.5
Angular version : 9.1
Related past issues
https://github.com/primefaces/primeng/issues/910
https://github.com/primefaces/primeng/issues/3147
The text was updated successfully, but these errors were encountered: