angularjs - Chrome 更新(angularjs 和 bootstrap-ui)后,当光标在模态之外释放时,模态关闭
问题描述
有时,当我想快速选择输入的整个文本(在模态中)时,我会从文本的末尾开始选择并将鼠标向左移动,直到整个文本被选中,然后松开.
有时这个释放会发生在模态之外,因为鼠标移动很快。
描述运动的图片:
问题是当我在外面释放时模态是关闭的。
问题:如何防止模态在外部释放时关闭?
我可以通过点击外部关闭模式。但是发布活动不行。
我在用着:
- 角度js 1.5.8
- angular-bootstrap 2.5.0(又名 bootstrap-ui)
- bootstrap 3.3.7(只有css!!!不是js,因为js是上面提供的)
更新: 我创建了一个 plunkr 和一个 GIF: https ://plnkr.co/edit/mxDLAdnrQ4p0KKyw?p=info
<div class="modal-body">
<div class="form-group">
<label for="">Foo</label>
<input type="text" class="form-control input-sm" ng-model="foo">
<p>Do this: select the text from right to left and release the mouse outside the modal.</p>
</div>
</div>
动图:
更新 2
我有新信息!这在上次 Goole Chrome 更新后开始发生!我尝试使用另一台装有旧版 Chrome 的计算机,但模式没有关闭。
解决方案
//prevent modal close when click starts in modal and ends on backdrop
$(document).on('mousedown', '.modal', function(e){
window.clickStartedInModal = $(e.target).is('.modal-dialog *');
});
$(document).on('mouseup', '.modal', function(e){
if(!$(e.target).is('.modal-dialog *') && window.clickStartedInModal) {
window.preventModalClose = true;
}
});
$("#modal").on("hide.bs.modal", function (e) {
if(window.preventModalClose){
window.preventModalClose = false;
return false;
}
});
推荐阅读
- node.js - 如何使用 Node.js child_process spawn 使用管道运行长时间运行的命令 [编辑:尤其是管道到 grep]
- python-3.x - 'requests' 不是内部或外部命令、可运行程序或批处理文件
- conditional-formatting - LibreOffice Calc:如何一次突出显示单元格范围的最大值?
- xaml - 悬停时使元素背景变暗
- javascript - 外部 JavaScript 文件不会更新 HTML 元素属性
- csv - Spark在字符串中使用逗号读取csv
- python - 检测增加和减少趋势
- python - 尝试使用 CSS 选择器和 Python/BeautifulSoup 从亚马逊页面抓取价格
- python - 使用 Selenium 单击所有 youtube 评论“回复”按钮并获取频道链接
- image - ZStack 中的 SwiftUI 大图像破坏了其他层的对齐方式