最近Chrome浏览器更新后,我的HTML输入字段默认为“只读”。

7

我的网站有几位用户向我解释说,无法再点击复选框或单击“添加文件”按钮(input type file)

在更新Google Chrome浏览器到版本92.0.4515.107之前,我无法复现这个问题

我发现我的一个CSS类覆盖了默认参数,因为Google Chrome将我的输入视为只读输入。

https://jsfiddle.net/Lfjctwb1/

示例:

<div class="form-check">
  <input class="form-check-input" type="checkbox" id="confirm-checkbox" required="">
  <label class="form-check-label" for="confirm-checkbox">
    <strong>I confirm</strong>
  </label>
</div>

<br>
<br> 

<input type="file" name="my_file" required />

我覆盖的 CSS 类:

.disabled, input:read-only {
    pointer-events: none;
}

如何修改我的类而不必修改所有的输入?

1
@ConstantinGroß,代码中没有其他引起此问题的内容。我刚刚确认了一下,在Chrome更新后它会触发:read-only。@Rocstar,也许你可以使用[readonly]选择器代替:read-only。另外,你真的需要那个类吗? - vanowm
1
你可能真的在Chrome中发现了一个bug...但是到目前为止,我还没有发现对我的任何项目产生影响...仍在努力弄清楚这里发生了什么!非常有趣! - Constantin Groß
1
你可能想在 https://bugs.chromium.org/p/chromium 上创建一个工单。 - Constantin Groß
@JohnPavek,情况并非如此。在HTTPS上提供的CSS中,没有表单的单个<input>也存在同样的问题。 - vanowm
并非所有的输入类型都受到影响,只有部分受到影响。问题已经报告:https://bugs.chromium.org/p/chromium/issues/detail?id=1259187 - Flash
显示剩余4条评论
网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接