Angular 角度-打开角度对话框时自动向下滚动到底部
我的项目中的“角度材质”对话框有问题, 当我打开一个对话框时,它会自动向下滚动到底部,当我关闭对话框时,它会在打开之前滚动回原始位置 我试图:Angular 角度-打开角度对话框时自动向下滚动到底部,angular,typescript,dialog,Angular,Typescript,Dialog,我的项目中的“角度材质”对话框有问题, 当我打开一个对话框时,它会自动向下滚动到底部,当我关闭对话框时,它会在打开之前滚动回原始位置 我试图: 在我的对话框配置中添加autoFocus:false 将我的app.module.ts文件中的BrowserAnimationModule更改为NoopAnimationModule 在对话框内容的我的按钮标记中添加tabindex=“-1” 但是没有任何效果,我使用了一个自定义CSS主题,没有任何JS文件, 我只使用材质来使用对话框 这是我的密码:
- 在我的对话框配置中添加
autoFocus:false
- 将我的app.module.ts文件中的
更改为BrowserAnimationModule
NoopAnimationModule
- 在对话框内容的我的按钮标记中添加
tabindex=“-1”
public openAddLinkDialog(): void {
this.dialog.open(AddLinkComponent).afterClosed().subscribe(data => {
if (data) {
console.log(data);
}
});
}
<div class="modal modal-right fade show" style="display: block;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Ajouter un lien</h5>
<button type="button" class="close" (click)="closeDialog()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body ps-container ps-theme-default">
<p>Test</p>
</div>
<div class="modal-footer modal-footer-uniform">
<button type="button" class="btn btn-bold btn-pure btn-secondary" (click)="closeDialog()">
Fermer
</button>
<button type="button" class="btn btn-bold btn-pure btn-primary" [disabled]="form.invalid" (click)="addLink()">
Ajouter
</button>
</div>
</div>
</div>
</div>
<div class="modal-backdrop fade show"></div>
public openAddLinkDialog():void{
this.dialog.open(AddLinkComponent).afterClosed().subscribe(数据=>{
如果(数据){
控制台日志(数据);
}
});
}
阿君连
×
试验
费尔默
阿约特
使用设置打开窗口时添加配置对象autoFocus:false
例如,这里:
const dialogRef=this.dialog.open(SomeComponent,{autoFocus:false})代码>
否则,窗口将滚动到第一个可聚焦元素,即您的按钮您可以在stackblitz上上传代码吗?