Skip to content

Commit

Permalink
update dropdown.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu authored May 6, 2022
1 parent 587f7bd commit ed3b308
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app/components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView
this.value = this.getOptionValue(this.selectedOption);
this.onModelChange(this.value);
}
else if (!this.selectedOption) {
this.value = null;
this.onModelChange(this.value);
}

this.selectedOptionUpdated = true;
}
Expand Down

5 comments on commit ed3b308

@yigitfindikli
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #8806

@dbk-anick
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi yigitfindikli and cetincakiroglu,
there is an error in the new line 607.
It should be
} else if (!this.editable && !this.selectedOption && this.value !== null) {
With your existing code there are problems, if the dropdown already is null or if it is editable.
Best regards,
Achim

@Cito
Copy link
Contributor

@Cito Cito commented on ed3b308 May 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbk-anick is right - see also #11522.

@cetincakiroglu
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbk-anick @Cito

Thanks for your report, we'll check.

@LucasBortolazzo
Copy link

@LucasBortolazzo LucasBortolazzo commented on ed3b308 May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cetincakiroglu ,
this change is causing problem in our application, especially when the control value is null. It seems that for it to work the "null" value needs to be inside the "option" of the p-dropdown. Apparently lines "608 and 609" are being executed improperly.

Version: 13.4.1

Problem description: When the formcontrol linked to p-dropdown has a null value, the lines "this.value = null and this.onModelChange(this.value)" are improperly executed, triggering a "valueChanges" event (changing the value to null) of the formControl and marking it as dirty improperly.
Captura de tela de 2022-05-31 16-28-31
Captura de tela de 2022-05-31 16-27-54
Captura de tela de 2022-05-31 14-49-47
Captura de tela de 2022-05-31 14-51-11

Regards

Please sign in to comment.