简体   繁体   English

屏幕阅读器忽略禁用属性

[英]Screen reader omits disabled attribute

I have a stepper - material UI number field.我有一个步进器 - 材质 UI 编号字段。 It is disabled but the screen reader is able to change the number (increment and decrement).它被禁用,但屏幕阅读器能够更改数字(递增和递减)。 HTML is as follows: HTML如下:

<input aria-invalid="false" id="outlined-number" type="number" class="MuiInputBase-input MuiOutlinedInput-input" disabled="true" value="3">

The disabled attribute is being specified wrong. disabled属性指定错误。 From https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes :https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes

2.4.2 Boolean attributes 2.4.2 布尔属性

A number of attributes are boolean attributes.许多属性是布尔属性。 The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.元素上布尔属性的存在表示真值,不存在该属性表示假值。

If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace.如果该属性存在,则其值必须是空字符串或与该属性的规范名称不区分大小写的 ASCII 匹配值,且没有前导或尾随空格。

The values "true" and "false" are not allowed on boolean attributes.布尔属性不允许使用值“true”和“false”。 To represent a false value, the attribute has to be omitted altogether.要表示假值,必须完全省略该属性。

Change the code to disabled="disabled" .将代码更改为disabled="disabled"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM