Skip to content

Commit 8a5181a

Browse files
author
Jens Vannerum
committed
documentation file
1 parent 2380d4e commit 8a5181a

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[DSpace ESLint plugins](../../../../lint/README.md) > [HTML rules](../index.md) > `dspace-angular-html/no-disabled-attribute-on-button`
2+
_______
3+
4+
Buttons should use the `dsBtnDisabled` directive instead of the HTML `disabled` attribute.
5+
This should be done to ensure that users with a screen reader are able to understand that the a button button is present, and that it is disabled.
6+
The native html disabled attribute does not allow users to navigate to the button by keyboard, and thus they have no way of knowing that the button is present.
7+
8+
_______
9+
10+
[Source code](../../../../lint/src/rules/html/no-disabled-attribute-on-button.ts)
11+
12+
### Examples
13+
14+
15+
#### Valid code
16+
17+
##### should use [dsBtnDisabled] in HTML templates
18+
19+
```html
20+
<button [dsBtnDisabled]="true">Submit</button>
21+
```
22+
23+
##### disabled attribute is still valid on non-button elements
24+
25+
```html
26+
<input disabled>
27+
```
28+
29+
##### [disabled] attribute is still valid on non-button elements
30+
31+
```html
32+
<input [disabled]="true">
33+
```
34+
35+
##### angular dynamic attributes that use disabled are still valid
36+
37+
```html
38+
<button [class.disabled]="isDisabled">Submit</button>
39+
```
40+
41+
42+
43+
44+
#### Invalid code &amp; automatic fixes
45+
46+
##### should not use disabled attribute in HTML templates
47+
48+
```html
49+
<button disabled>Submit</button>
50+
```
51+
Will produce the following error(s):
52+
```
53+
Buttons should use the `dsBtnDisabled` directive instead of the `disabled` attribute.
54+
```
55+
56+
Result of `yarn lint --fix`:
57+
```html
58+
<button [dsBtnDisabled]="true">Submit</button>
59+
```
60+
61+
62+
##### should not use [disabled] attribute in HTML templates
63+
64+
```html
65+
<button [disabled]="true">Submit</button>
66+
```
67+
Will produce the following error(s):
68+
```
69+
Buttons should use the `dsBtnDisabled` directive instead of the `disabled` attribute.
70+
```
71+
72+
Result of `yarn lint --fix`:
73+
```html
74+
<button [dsBtnDisabled]="true">Submit</button>
75+
```
76+
77+
78+

0 commit comments

Comments
 (0)