Skip to content

Commit

Permalink
fix: setTouched on Select Close instead of Open (#231)
Browse files Browse the repository at this point in the history
closes #225 
This will set `touched` on closing the option instead of open.
A typical HTML Select in Angular will set touched once the user
mouse clicks out or tabs (keyboard) out. This will emulate that
same behaviour. Setting `touched` right away on open causes
weird user experience when displaying error message that 
typically depend on `touched` being set. We want to let
the user interact with the select and once done interaction,
it is to be set `touched`.
  • Loading branch information
RanadeepPolavarapu authored and anjmao committed Feb 4, 2018
1 parent 92b347d commit 50a2e3c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng-select/ng-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ export class NgSelectComponent implements OnInit, OnDestroy, OnChanges, AfterVie
this.itemsList.markSelectedOrDefault(this.markFirst);
this._scrollToMarked();
this._focusSearchInput();
this._onTouched();
this.openEvent.emit();
if (this.appendTo) {
this._updateDropdownPosition();
Expand All @@ -289,6 +288,7 @@ export class NgSelectComponent implements OnInit, OnDestroy, OnChanges, AfterVie
}
this.isOpen = false;
this._clearSearch();
this._onTouched();
this.closeEvent.emit();
}

Expand Down

0 comments on commit 50a2e3c

Please sign in to comment.