From 8f607040e383a213ba63eace77a5d5cef3f3bc72 Mon Sep 17 00:00:00 2001 From: Hsuan Lee Date: Thu, 25 Apr 2019 17:40:21 +0800 Subject: [PATCH] fix(module:auto-complete): enter-keydown event should not be prevent when the panel is closed (#3342) * fix(module:auto-complete): enter-keydown event should not be prevent when the panel is closed close #3340 * chore(module:auto-complete): clean code --- components/auto-complete/nz-autocomplete-trigger.directive.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/auto-complete/nz-autocomplete-trigger.directive.ts b/components/auto-complete/nz-autocomplete-trigger.directive.ts index 1e0ea139a85..cdae56fcf01 100644 --- a/components/auto-complete/nz-autocomplete-trigger.directive.ts +++ b/components/auto-complete/nz-autocomplete-trigger.directive.ts @@ -156,12 +156,13 @@ export class NzAutocompleteTriggerDirective implements ControlValueAccessor, OnD } this.closePanel(); } else if (this.panelOpen && keyCode === ENTER) { - event.preventDefault(); if (this.nzAutocomplete.showPanel && this.activeOption) { + event.preventDefault(); this.activeOption.selectViaInteraction(); } } else if (this.panelOpen && isArrowKey && this.nzAutocomplete.showPanel) { event.stopPropagation(); + event.preventDefault(); if (keyCode === UP_ARROW) { this.nzAutocomplete.setPreviousItemActive(); } else {