在 mat-dialog 中聚焦 iFrame

Focus iFrame in mat-dialog

我正在使用 mat-dialog 显示在 google-slides 中创建的其中一张幻灯片。打开对话框后,我希望用户使用箭头键浏览幻灯片。但这仅在用户第一次手动单击幻灯片时有效。 这里的问题是,我无法将焦点放在 iFrame 中。下面是模拟我的用例的代码片段。

https://stackblitz.com/edit/mat-dialog-example-9ttgpd

我试过使用 this.iframe.nativeElement.contentWindow.focus() 但没有成功。是否有任何其他技术可以在演示文稿中引入焦点?

您可以尝试等待 iframe 加载

<iframe ... (load)="$event.target.contentWindow.focus()">

Forked Stackblitz