Skip to content

Commit

Permalink
fix(module:select): fix select scroll top trigger (#3285)
Browse files Browse the repository at this point in the history
close #3258
  • Loading branch information
vthinkxie authored Apr 17, 2019
1 parent 2845b57 commit 1478e59
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions components/select/demo/automatic-tokenization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ import { Component, OnInit } from '@angular/core';
@Component({
selector: 'nz-demo-select-automatic-tokenization',
template: `
<nz-select nzMode="tags" [nzTokenSeparators]="[',']" style="width: 100%;" [(ngModel)]="listOfTagOptions">
<nz-select
nzMode="tags"
[nzTokenSeparators]="[',']"
style="width: 100%;"
[(ngModel)]="listOfTagOptions"
nzPlaceHolder="automatic tokenization"
>
<nz-option *ngFor="let option of listOfOption" [nzLabel]="option.label" [nzValue]="option.value"> </nz-option>
</nz-select>
`
})
export class NzDemoSelectAutomaticTokenizationComponent implements OnInit {
listOfOption: Array<{ label: string; value: string }> = [];
listOfTagOptions = null;
listOfTagOptions = [];

ngOnInit(): void {
const children: Array<{ label: string; value: string }> = [];
Expand Down
2 changes: 1 addition & 1 deletion components/select/demo/select-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class NzDemoSelectSelectUsersComponent implements OnInit {
randomUserUrl = 'https://api.randomuser.me/?results=5';
searchChange$ = new BehaviorSubject('');
optionList: string[] = [];
selectedUser = '';
selectedUser: string;
isLoading = false;

onSearch(value: string): void {
Expand Down
4 changes: 3 additions & 1 deletion components/select/nz-option-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { NzSelectService } from './nz-select.service';
})
export class NzOptionContainerComponent implements OnDestroy, OnInit {
private destroy$ = new Subject();
private lastScrollTop = 0;
@ViewChildren(NzOptionLiComponent) listOfNzOptionLiComponent: QueryList<NzOptionLiComponent>;
@ViewChild('dropdownUl') dropdownUl: ElementRef;
@Input() nzNotFoundContent: string;
Expand Down Expand Up @@ -78,7 +79,8 @@ export class NzOptionContainerComponent implements OnDestroy, OnInit {
.subscribe(e => {
e.preventDefault();
e.stopPropagation();
if (ul && ul.scrollHeight < ul.clientHeight + ul.scrollTop + 10) {
if (ul && ul.scrollTop > this.lastScrollTop && ul.scrollHeight < ul.clientHeight + ul.scrollTop + 10) {
this.lastScrollTop = ul.scrollTop;
this.ngZone.run(() => {
this.nzScrollToBottom.emit();
});
Expand Down

0 comments on commit 1478e59

Please sign in to comment.