Skip to content

Commit

Permalink
fix(module:dropdown): fix dropdown disabled button (#5429)
Browse files Browse the repository at this point in the history
close #5258
  • Loading branch information
Yadong Xie authored Jun 16, 2020
1 parent 48614c0 commit 797c65d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions components/dropdown/dropdown.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
OnDestroy,
OnInit,
Output,
Renderer2,
SimpleChanges,
ViewContainerRef
} from '@angular/core';
Expand All @@ -33,7 +34,6 @@ const listOfPositions = [POSITION_MAP.bottomLeft, POSITION_MAP.bottomRight, POSI
selector: '[nz-dropdown]',
exportAs: 'nzDropdown',
host: {
'[attr.disabled]': `nzDisabled ? '' : null`,
'[class.ant-dropdown-trigger]': 'true'
}
})
Expand Down Expand Up @@ -71,6 +71,7 @@ export class NzDropDownDirective implements AfterViewInit, OnDestroy, OnChanges,
constructor(
public elementRef: ElementRef,
private overlay: Overlay,
private renderer: Renderer2,
private viewContainerRef: ViewContainerRef,
private platform: Platform
) {}
Expand Down Expand Up @@ -189,8 +190,14 @@ export class NzDropDownDirective implements AfterViewInit, OnDestroy, OnChanges,
if (nzVisible) {
this.inputVisible$.next(this.nzVisible);
}
if (nzDisabled && this.nzDisabled) {
this.inputVisible$.next(false);
if (nzDisabled) {
const nativeElement = this.elementRef.nativeElement;
if (this.nzDisabled) {
this.renderer.setAttribute(nativeElement, 'disabled', '');
this.inputVisible$.next(false);
} else {
this.renderer.removeAttribute(nativeElement, 'disabled');
}
}
if (nzOverlayClassName) {
this.setDropdownMenuValue('nzOverlayClassName', this.nzOverlayClassName);
Expand Down

0 comments on commit 797c65d

Please sign in to comment.