Skip to content

Commit

Permalink
fix(module:select): arrow icon can be used when not using single-sele…
Browse files Browse the repository at this point in the history
…ct (#5785)

* fix(module:select): arrow icon can be used when not using single-select

* docs(module:select): update docs according to the fix

* fix(module:select): fix get statement


close #5575
  • Loading branch information
Depickere Sven authored Sep 16, 2020
1 parent 2d3a49c commit bb8677c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion components/select/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { NzSelectModule } from 'ng-zorro-antd/select';
| `[nzMode]` | Set mode of Select | `'multiple' \| 'tags' \| 'default'` | `'default'` |
| `[nzNotFoundContent]` | Specify content to show when no result matches.. | `string \| TemplateRef<void>` | `'Not Found'` |
| `[nzPlaceHolder]` | Placeholder of select | `string` | - |
| `[nzShowArrow]` | Whether to show the drop-down arrow | `boolean` | `true` |
| `[nzShowArrow]` | Whether to show the drop-down arrow | `boolean` | `true`(for single select), `false`(for multiple select) |
| `[nzShowSearch]` | Whether show search input in single mode. | `boolean` | `false` |
| `[nzSize]` | Size of Select input | `'large' \| 'small' \| 'default'` | `'default'` |
| `[nzSuffixIcon]` | The custom suffix icon | `TemplateRef<any> \| string` | - ||
Expand Down
2 changes: 1 addition & 1 deletion components/select/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { NzSelectModule } from 'ng-zorro-antd/select';
| `[nzMode]` | 设置 nz-select 的模式 | `'multiple' \| 'tags' \| 'default'` | `'default'` |
| `[nzNotFoundContent]` | 当下拉列表为空时显示的内容 | `string \| TemplateRef<void>` | - |
| `[nzPlaceHolder]` | 选择框默认文字 | `string` | - |
| `[nzShowArrow]` | 是否显示下拉小箭头 | `boolean` | `true` |
| `[nzShowArrow]` | 是否显示下拉小箭头 | `boolean` | 单选为 `true`,多选为 `false` |
| `[nzShowSearch]` | 使单选模式可搜索 | `boolean` | `false` |
| `[nzSize]` | 选择框大小 | `'large' \| 'small' \| 'default'` | `'default'` |
| `[nzSuffixIcon]` | 自定义的选择框后缀图标 | `TemplateRef<any> \| string` | - ||
Expand Down
15 changes: 12 additions & 3 deletions components/select/select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export type NzSelectSizeType = 'large' | 'default' | 'small';
(clear)="onClearSelection()"
></nz-select-clear>
<nz-select-arrow
*ngIf="nzShowArrow && nzMode === 'default'"
*ngIf="nzShowArrow"
[loading]="nzLoading"
[search]="nzOpen && nzShowSearch"
[suffixIcon]="nzSuffixIcon"
Expand Down Expand Up @@ -148,7 +148,7 @@ export type NzSelectSizeType = 'large' | 'default' | 'small';
'[class.ant-select]': 'true',
'[class.ant-select-lg]': 'nzSize === "large"',
'[class.ant-select-sm]': 'nzSize === "small"',
'[class.ant-select-show-arrow]': `nzShowArrow && nzMode === 'default'`,
'[class.ant-select-show-arrow]': `nzShowArrow`,
'[class.ant-select-disabled]': 'nzDisabled',
'[class.ant-select-show-search]': `(nzShowSearch || nzMode !== 'default') && !nzDisabled`,
'[class.ant-select-allow-clear]': 'nzAllowClear',
Expand Down Expand Up @@ -189,7 +189,6 @@ export class NzSelectComponent implements ControlValueAccessor, OnInit, AfterVie
@Input() nzClearIcon: TemplateRef<NzSafeAny> | null = null;
@Input() nzRemoveIcon: TemplateRef<NzSafeAny> | null = null;
@Input() nzMenuItemSelectedIcon: TemplateRef<NzSafeAny> | null = null;
@Input() nzShowArrow = true;
@Input() nzTokenSeparators: string[] = [];
@Input() nzMaxTagPlaceholder: TemplateRef<{ $implicit: NzSafeAny[] }> | null = null;
@Input() nzMaxMultipleCount = Infinity;
Expand All @@ -206,6 +205,15 @@ export class NzSelectComponent implements ControlValueAccessor, OnInit, AfterVie
@Input() @InputBoolean() nzDisabled = false;
@Input() @InputBoolean() nzOpen = false;
@Input() nzOptions: NzSelectOptionInterface[] = [];

@Input()
set nzShowArrow(value: boolean) {
this._nzShowArrow = value;
}
get nzShowArrow(): boolean {
return this._nzShowArrow === undefined ? this.nzMode === 'default' : this._nzShowArrow;
}

@Output() readonly nzOnSearch = new EventEmitter<string>();
@Output() readonly nzScrollToBottom = new EventEmitter<void>();
@Output() readonly nzOpenChange = new EventEmitter<boolean>();
Expand All @@ -225,6 +233,7 @@ export class NzSelectComponent implements ControlValueAccessor, OnInit, AfterVie
private isReactiveDriven = false;
private value: NzSafeAny | NzSafeAny[];
private destroy$ = new Subject();
private _nzShowArrow: boolean | undefined;
onChange: OnChangeType = () => {};
onTouched: OnTouchedType = () => {};
dropDownPosition: 'top' | 'center' | 'bottom' = 'bottom';
Expand Down

0 comments on commit bb8677c

Please sign in to comment.