Skip to content

Commit

Permalink
Merge pull request #12457 from primefaces/issue-12455
Browse files Browse the repository at this point in the history
Fixed #12455 - p-dropdown: option displays empty when value is 0 (zer…
  • Loading branch information
cetincakiroglu committed Jan 4, 2023
2 parents f99eae2 + 2082f00 commit 39393f6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app/components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface DropdownFilterOptions {
[id]="selected ? 'p-highlighted-option' : ''"
[ngClass]="{ 'p-dropdown-item': true, 'p-highlight': selected, 'p-disabled': disabled }"
>
<span *ngIf="!template">{{ label || 'empty' }}</span>
<span *ngIf="!template">{{ label ?? 'empty' }}</span>
<ng-container *ngTemplateOutlet="template; context: { $implicit: option }"></ng-container>
</li>
`,
Expand All @@ -69,6 +69,7 @@ export class DropdownItem {
@Input() option: SelectItem;

@Input() selected: boolean;
_label: string;

@Input() label: string;

Expand Down Expand Up @@ -646,6 +647,10 @@ export class Dropdown implements OnInit, AfterViewInit, AfterContentInit, AfterV
}

get label(): string {
if (typeof this.selectedOption === 'number') {
this.selectedOption = this.selectedOption.toString();
}

return this.selectedOption ? this.getOptionLabel(this.selectedOption) : null;
}

Expand Down

0 comments on commit 39393f6

Please sign in to comment.