角度6垫对话框自动向下滚动到底部 [英] angular 6 mat-dialog scroll down to bottom automatically

查看:140
本文介绍了角度6垫对话框自动向下滚动到底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

打开mat-dialog时,我会自动向下滚动.我有2个引起问题的按钮(我认为),但是我不知道该怎么做才能解决问题.

I have an issue with scroll down automatically when open the mat-dialog. I have 2 buttons that cause the the problem (I assume) but I didn't figure out what to do to resolve the issue.

component.ts代码:

The component.ts code :

 openDialog(): void {
let dialogRef = this.dialog.open(FileBrowserComponent, { 
       height: '600px',
       width: '700px',
});

对话框html代码:

<div class="container">

<div class="img" *ngFor="let element of fileElements">
    <img src="{{assetsFullUrl(element.name)}}" alt="{{element.name}}" (dblclick)="selectedImage===true">
</div>

</div>

<vaadin-upload target="http://localhost:3000/assets/upload" method="POST" 
accept="image/*"></vaadin-upload>

<div class="buttons">
<button mat-raised-button color='primary' type="button" (click)="add()">Save</button>
<button mat-raised-button color='basic' type="button" (click)="cancel()">Cancel</button>
</div>

感谢您的帮助.

推荐答案

根据文档,第一个可制表的元素将重点突出.您可以分配 tabindex =-1" 来防止按钮聚焦

According to the documentation, the first tabable element will be focused. You can assign tabindex="-1" to prevent the buttons from getting focused

<button mat-raised-button tabindex="-1">Not Tabbable</button>

这篇关于角度6垫对话框自动向下滚动到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆