Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(module:dropdown): unable to set bool attr to false #8620

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/dropdown/dropdown.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ export class NzDropDownDirective implements AfterViewInit, OnDestroy, OnChanges
if (nzTrigger) {
this.nzTrigger$.next(this.nzTrigger);
}
if (nzVisible) {
if (nzVisible !== undefined) {
this.inputVisible$.next(this.nzVisible);
}
if (nzDisabled) {
if (nzDisabled !== undefined) {
Comment on lines +208 to +211
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here, nzVisible and nzDisabled are of type SimpleChange, not boolean. So I guess we don't need to use undefined to determine that, WDYT?

Copy link
Author

Choose a reason for hiding this comment

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

nzVisible and nzDisabled receive boolean values externally, but when fetching their values from the changes object, there can be three possible scenarios: undefined (when the external value has not been changed), true (change to true from false), or false (change to false from true). However, if the code logic is simply if(nzVisible), it will only process the case where it is true. When the external source intends to change it to false, it will not take effect as expected.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you misunderstood that when nzDisabled is changed to false, changes.nzDisabled is of type SimpleChange, not boolean, because it's changes.nzDisabled, not this.nzDisabled.

const nativeElement = this.elementRef.nativeElement;
if (this.nzDisabled) {
this.renderer.setAttribute(nativeElement, 'disabled', '');
Expand Down