【发布时间】:2020-07-20 07:22:14
【问题描述】:
我正在处理芯片,在设置水平滚动以垫芯片后,我发现了这个问题 如果您在向下滚动后单击垫子上的任何位置,它将自动向上滚动到顶部。 在 stackblitz 上测试垫芯片的原始代码后,我发现垫芯片具有此功能,但默认设置。我需要防止这种情况发生。
这是我的 HTML 代码
> <div class="callTags robotoRegular">
<div class="wrapper">
<div class="box">
<div class="boxWrapper">
<div class="title">
<span class="boxTitle">{{ 'multiWrapupTags.categories.title' | translate}}</span>
</div>
<mat-form-field appearance="none" class="example-chip-list">
<mat-chip-list #chipList1 >
<div class="selectedTags" id="catScroll">
<mat-chip
*ngFor="let category of selectedCategories"
[selectable]="selectable"
[removable]="removable"
(removed)="remove(category, 'category')">
<span >
{{category.Name}}
</span>
<mat-icon matChipRemove *ngIf="removable">cancel</mat-icon>
</mat-chip>
<input
#fruitInput
class="robotoRegular"
[formControl]="categoriesForm"
[matAutocomplete]="auto1"
[matChipInputFor]="chipList1"
(ngModelChange)="change($event, 'category')"
placeholder="Select Category"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
(matChipInputTokenEnd)="add($event, 'category')">
</div>
<div class="d-flex">
<div class="d-flex flex-column ">
<button id="up"><span class="material-icons"> keyboard_arrow_up </span></button>
<button id="down"><span class="material-icons"> keyboard_arrow_down </span></button>
</div>
<button mat-button (click)="deleteAll('category')">Clear</button>
</div>
</mat-chip-list>
<mat-autocomplete #auto1="matAutocomplete">
<mat-option *ngFor="let category of filteredCategories; let i = index" [value]="category.Name" (click)="selected(category, 'category')">
<div>{{category.Name}}</div>
</mat-option>
</mat-autocomplete>
</mat-form-field>
<div class="count">
<span >{{selectedCategories.length}}</span>
</div>
</div>
</div>
<!-- subCategories -->
<div class="box subCategories">
<div class="boxWrapper">
<div class="title">
<span class="boxTitle">{{ 'multiWrapupTags.subCategories.title' | translate}}</span>
</div>
<mat-form-field appearance="none" class="example-chip-list">
<mat-chip-list #chipList2 aria-label="Fruit selection">
<div class="selectedTags wrapups" id='scrol'>
<mat-chip
*ngFor="let subCat of selectedWrapUps"
[selectable]="selectable"
[removable]="removable"
(removed)="remove(subCat, 'wrapup')">
<span class="
">
{{subCat.Name}}
</span>
<mat-icon matChipRemove *ngIf="removable">cancel</mat-icon>
</mat-chip>
<input
#categoryInput
class="robotoRegular"
[formControl]="subcategoriesForm"
[matAutocomplete]="auto2"
[matChipInputFor]="chipList2"
placeholder="Select Wrapup"
(ngModelChange)="change($event, 'wrapup')"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
(matChipInputTokenEnd)="add($event, 'wrapup')">
</div>
<div class="d-flex">
<div class="d-flex flex-column ">
<button id="up"><span class="material-icons"> keyboard_arrow_up </span></button>
<button id="down"><span class="material-icons"> keyboard_arrow_down </span></button>
</div>
<button mat-button (click)="deleteAll('wrapup')">Clear</button>
</div>
</mat-chip-list>
<mat-autocomplete #auto2="matAutocomplete">
<mat-option *ngFor="let subCategory of filteredWrapUps" [value]="subCategory.Name" (click) = "selected(subCategory, 'wrapup')">
{{subCategory.Name}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
<div class="count">
<span >{{selectedWrapUps.length}}</span>
</div>
</div>
</div>
<div class="box tagsBox">
<div class="boxWrapper">
<div class="title">
<span class="boxTitle">{{ 'multiWrapupTags.tags.title' | translate}}</span>
</div>
<mat-form-field appearance="none" class="example-chip-list">
<mat-chip-list #chipList3 aria-label="Fruit selection">
<div class="selectedTags">
<mat-chip
*ngFor="let tag of selectedTags"
[selectable]="selectable"
[removable]="removable"
(removed)="remove(tag, 'tags')">
<span class="
">
{{tag.Name}}
</span>
<mat-icon matChipRemove *ngIf="removable">cancel</mat-icon>
</mat-chip>
<input
#fruitInput
class="robotoRegular"
[formControl]="tagsForm"
[matAutocomplete]="auto3"
[matChipInputFor]="chipList3"
placeholder="Select Tag"
(ngModelChange)="change($event, 'tags')"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
(matChipInputTokenEnd)="add($event, 'tags')">
</div>
<div class="d-flex">
<div class="d-flex flex-column ">
<button id="up"><span class="material-icons"> keyboard_arrow_up </span></button>
<button id="down"><span class="material-icons"> keyboard_arrow_down </span></button>
</div>
<button mat-button (click)="deleteAll('tags')">Clear</button>
</div>
</mat-chip-list>
<mat-autocomplete #auto3="matAutocomplete">
<mat-option *ngFor="let tag of filteredTags" [value]="tag.Name" (click)="selected(tag, 'tags')">
{{tag.Name}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
<div class="count">
<span >{{selectedTags.length}}</span>
</div>
</div>
</div>
<button mat-stroked-button (click)="onCallEnded()" aria-label="Show an example snack-bar">
Success Notification
</button>
</div>
</div>
【问题讨论】:
标签: angular angular-material angular8 angular-material2