【发布时间】:2021-03-25 15:40:34
【问题描述】:
我正在使用来自Angular Material 的Tooltip,但工具提示无法在 iOS (Safari) 上正确显示。这是我遇到的行为:
- 装有 iOS 12 的 iPhone:长按按钮会显示工具提示,但也会执行
click事件 - 装有 iOS 13 的 iPad:长按时根本没有工具提示
- 装有 iOS 14 的 iPhone:长按时会显示工具提示,但会出现弹出菜单(剪切、复制、粘贴...)并选择下面的文本
在 Android 上,一切都按预期工作。在我看来,matTooltip 根本无法在 iOS 上运行。这是我的设置:
Angular CLI:8.3.29
角度:8.2.14
@angular/cdk 8.2.3
@角/材料8.2.3
我的示例代码基于this here:
app.component.html
<button mat-raised-button
matTooltip="Info about the action"
aria-label="Button that displays a tooltip when focused or hovered over"
(click)="clickEvent()">
Action
</button>
app.component.css:
* {
-webkit-touch-callout: none;
-webkit-user-select: none; /* Disable selection/copy in UIWebView */
}
app.component.ts:
import { Component } from '@angular/core';
import {MatDialog, MatDialogConfig} from '@angular/material';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'tooltip';
constructor(private dialog: MatDialog) {}
clickEvent(){
window.alert('clicked');
}
}
app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import {MatTooltipModule} from '@angular/material/tooltip';
import {MatButtonModule} from '@angular/material/button';
import {MatDialogModule} from '@angular/material';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NoopAnimationsModule,
MatTooltipModule,
MatButtonModule,
MatDialogModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
我尝试应用特殊的 CSS(见上文),但该 CSS 必须以不同的方式应用才能生效。但是元素仍然存在问题,无法选择(例如在表单中)。
这是一个错误还是我遗漏了什么?
【问题讨论】:
标签: ios angular angular-material tooltip angular-material2