javascript - 由于 mouseup 事件,模态消失(在模态中突出显示输入字段并在模态外释放鼠标)
问题描述
一个有趣的错误,其中您有一个带有表单输入字段的模式。然后突出显示其中一个输入字段中的文本,因此mousedown事件发生在模式内部,但mouseup事件发生在模式外部。
Chrome 73 将模态框外的 mouseup 事件解释为点击,并关闭模态框。
这是原始模式代码:
<div class="modal-wrapper" (click)="close()">
<div class="modal-background"></div>
<div class="modal-container" (click)="stopEvent($event)">
<!-- modal content here -->
</div>
</div>
解决方案
解决方案是将关闭模式的单击事件更改为 mousedown 事件:
<div class="modal-wrapper" (mousedown)="close()">
<div class="modal-background"></div>
<div class="modal-container" (mousedown)="stopEvent($event)">
<!-- modal content here -->
</div>
</div>
推荐阅读
- elasticsearch - 电报输出到 Elasticsearch:“健康检查超时:没有可用的 Elasticsearch 节点”
- r - 如何查找数据框中两列的异常值
- azure - Azure - 用于 Web 应用程序的 js、css 文件的浏览器缓存设置
- mysql - 在创建 Elastic Beanstalk 环境时,有什么方法可以在创建时在 RDS MySQL 实例中创建触发器和存储过程?
- c++ - C++ 检查结构是否为空
- java - 如何获取给定城市或地址名称的纬度和经度(java代码)?
- apache-flink - Flink 大尺寸/小提前滑动窗口性能
- javascript - 如何从日期选择器中排除前一个日期
- scala - 如何使用 Numeric[T] 表示任何数字类型的零
- php - Laravel whereDate 用户时区