From 7dd462fb1aeb6123c229a22a5a49645b75124f6c Mon Sep 17 00:00:00 2001 From: bbcodrin Date: Wed, 20 Jun 2018 15:08:46 +0300 Subject: [PATCH] [ADF-3229] people widget list reseted if empty input (#3507) * list reseted when input is empty * test added --- .../components/widgets/people/people.widget.spec.ts | 12 ++++++++++++ .../form/components/widgets/people/people.widget.ts | 1 + 2 files changed, 13 insertions(+) diff --git a/lib/core/form/components/widgets/people/people.widget.spec.ts b/lib/core/form/components/widgets/people/people.widget.spec.ts index fc8523cd67..70298d1c01 100644 --- a/lib/core/form/components/widgets/people/people.widget.spec.ts +++ b/lib/core/form/components/widgets/people/people.widget.spec.ts @@ -169,6 +169,18 @@ describe('PeopleWidgetComponent', () => { }); })); + it('should hide result list if input is empty', () => { + let peopleHTMLElement: HTMLInputElement = element.querySelector('input'); + peopleHTMLElement.focus(); + peopleHTMLElement.value = ''; + peopleHTMLElement.dispatchEvent(new Event('keyup')); + peopleHTMLElement.dispatchEvent(new Event('input')); + fixture.detectChanges(); + fixture.whenStable().then(() => { + fixture.detectChanges(); + expect(fixture.debugElement.query(By.css('#adf-people-widget-user-0'))).toBeNull(); + }); + }); }); }); diff --git a/lib/core/form/components/widgets/people/people.widget.ts b/lib/core/form/components/widgets/people/people.widget.ts index 3449453ef3..bc8117c6c2 100644 --- a/lib/core/form/components/widgets/people/people.widget.ts +++ b/lib/core/form/components/widgets/people/people.widget.ts @@ -80,6 +80,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { this.checkUserAndValidateForm(list, value); } else { this.field.value = null; + list = []; } return list;