Skip to content

Commit

Permalink
Fixed #14427
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed Dec 28, 2023
1 parent b3ae34d commit 46626af
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/app/components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,14 +928,14 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
const modelValue = this.modelValue();
const visibleOptions = this.visibleOptions();

if (modelValue && this.editable) {
this.updateEditableLabel();
}

if (visibleOptions && ObjectUtils.isNotEmpty(visibleOptions)) {
this.selectedOption = visibleOptions[this.findSelectedOptionIndex()];
this.cd.markForCheck();
}

if (modelValue && this.editable) {
this.updateEditableLabel();
}
});
}

Expand Down Expand Up @@ -1103,7 +1103,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV

updateEditableLabel(): void {
if (this.editableInputViewChild) {
this.editableInputViewChild.nativeElement.value = this.getOptionLabel(this.modelValue()) === undefined ? this.editableInputViewChild.nativeElement.value : this.getOptionLabel(this.modelValue());
this.editableInputViewChild.nativeElement.value = ObjectUtils.isNotEmpty(this.selectedOption) ? this.getOptionLabel(this.selectedOption) : this.editableInputViewChild.nativeElement.value;
}
}

Expand Down Expand Up @@ -1200,6 +1200,8 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
this.onModelChange(value);
this.updateModel(value, event);
this.onChange.emit({ originalEvent: event, value: value });

!this.overlayVisible && ObjectUtils.isNotEmpty(value) && this.show();
}
/**
* Displays the panel.
Expand All @@ -1213,6 +1215,7 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
if (isFocus) {
DomHandler.focus(this.focusInputViewChild?.nativeElement);
}

this.cd.markForCheck();
}

Expand Down Expand Up @@ -1263,8 +1266,14 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
if (this.filter && this.resetFilterOnHide) {
this.resetFilter();
}

isFocus && DomHandler.focus(this.focusInputViewChild?.nativeElement);
if (isFocus) {
if (this.focusInputViewChild) {
DomHandler.focus(this.focusInputViewChild?.nativeElement);
}
if (this.editable && this.editableInputViewChild) {
DomHandler.focus(this.editableInputViewChild?.nativeElement);
}
}
this.cd.markForCheck();
}

Expand Down

0 comments on commit 46626af

Please sign in to comment.