@@ -681,6 +681,8 @@ function App() {
681681
682682 < label htmlFor = "tel" > Phone Number</ label >
683683 < input id = "tel" type = "tel" />
684+
685+ < button type = "submit" > Submit</ button >
684686 </ form >
685687
686688 < div >
@@ -1124,30 +1126,35 @@ function App() {
11241126 < p > Users can navigate to and from all content using a keyboard.</ p >
11251127 </ header >
11261128
1127- < div >
1128- < button > Button before the trap</ button >
1129+ < div
1130+ role = "menu"
1131+ aria-label = "Example Menu"
1132+ className = { styles . keyboardTrap } >
1133+ < div role = "menuitem" tabIndex = { 0 } >
1134+ Menu item before the trap
1135+ </ div >
11291136
11301137 < div
1131- className = { styles . keyboardTrap }
1138+ role = "menuitem"
11321139 tabIndex = { 0 }
11331140 onKeyDown = { event => {
1134- // Prevent users from tabbing out of this container
1141+ // Prevent users from tabbing out of this element
11351142 if ( event . key === 'Tab' ) {
11361143 event . preventDefault ( ) ;
11371144 }
11381145 } } >
1139- < h4 > Keyboard Trap</ h4 >
1140- < p >
1146+ Keyboard trap
1147+ < br />
1148+ < small >
11411149 This container traps keyboard focus by blocking the < kbd > Tab</ kbd > { ' ' }
11421150 key.
1143- </ p >
1144- < button > Keyboard focus is trapped after clicking me</ button >
1151+ </ small >
11451152 </ div >
11461153
1147- < button >
1148- Button after the trap < wbr />
1154+ < div role = "menuitem" tabIndex = { 0 } >
1155+ Menu item after the trap < wbr />
11491156 (not reachable)
1150- </ button >
1157+ </ div >
11511158 </ div >
11521159
11531160 < div >
@@ -1472,7 +1479,7 @@ function App() {
14721479 </ header >
14731480
14741481 < div className = { styles . multipleWays } >
1475- < nav role = "tablist" >
1482+ < div role = "tablist" >
14761483 { MULTIPLE_WAYS_TABS . map ( ( tab , index ) => (
14771484 < button
14781485 key = { tab }
@@ -1488,7 +1495,7 @@ function App() {
14881495 { tab }
14891496 </ button >
14901497 ) ) }
1491- </ nav >
1498+ </ div >
14921499
14931500 < div role = "tabpanel" tabIndex = { 0 } aria-labelledby = { activeTab } >
14941501 < h3 > { activeTab } </ h3 >
@@ -1973,7 +1980,7 @@ function App() {
19731980 < form
19741981 onSubmit = { event => {
19751982 event . preventDefault ( ) ;
1976- alert ( 'Form auto-! !' ) ;
1983+ alert ( 'Form auto-submitted !' ) ;
19771984 } } >
19781985 < label >
19791986 < input
@@ -1993,8 +2000,8 @@ function App() {
19932000 < h3 > Why this violates the rule</ h3 >
19942001 < ul >
19952002 < li >
1996- The form is ! immediately when the checkbox is checked — without
1997- user confirmation.
2003+ The form is submitted immediately when the checkbox is checked —
2004+ without user confirmation.
19982005 </ li >
19992006 < li >
20002007 Users may not expect a form to submit from a checkbox alone.
@@ -2036,7 +2043,7 @@ function App() {
20362043 : [ 'Services' , 'Home' , 'Contact' , 'About' ]
20372044 ) . map ( link => (
20382045 < li key = { link } >
2039- < a href = "#" > { link } </ a >
2046+ < a href = { `# ${ link . toLowerCase ( ) } ` } > { link } </ a >
20402047 </ li >
20412048 ) ) }
20422049 </ ul >
@@ -2096,6 +2103,12 @@ function App() {
20962103 < dialog ref = { consistentIdentificationDialogRef } >
20972104 < p > { consistentIdentificationModalContent } </ p >
20982105 < button
2106+ /**
2107+ * It's safe to disable the no-autofocus rule here because:
2108+ * - The button is inside a modal <dialog>, which demands immediate keyboard focus.
2109+ * - This improves accessibility by allowing keyboard and screen reader users to act quickly.
2110+ */
2111+ // eslint-disable-next-line jsx-a11y/no-autofocus
20992112 autoFocus
21002113 onClick = { ( ) => {
21012114 setConsistentIdentificationModalContent ( null ) ;
@@ -2140,15 +2153,15 @@ function App() {
21402153 < h3 > Page 1</ h3 >
21412154 < p > Content of page 1</ p >
21422155 < div className = { styles . helpLinkTopRight } >
2143- < a href = "#" > Need help?</ a >
2156+ < a href = "#help " > Need help?</ a >
21442157 </ div >
21452158 </ div >
21462159
21472160 < div className = { styles . page } >
21482161 < h3 > Page 2</ h3 >
21492162 < p > Content of page 2</ p >
21502163 < div className = { styles . helpLinkBottomLeft } >
2151- < a href = "#" > Support</ a >
2164+ < a href = "#support " > Support</ a >
21522165 </ div >
21532166 </ div >
21542167 </ div >
@@ -2480,6 +2493,11 @@ function App() {
24802493 </ header >
24812494
24822495 < div className = { styles . nameRoleValue } >
2496+ { /**
2497+ * This is an intentionally inaccessible "checkbox"
2498+ * without role, name, and keyboard support.
2499+ */ }
2500+ { /* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */ }
24832501 < div
24842502 className = { styles . checkbox }
24852503 onClick = { ( ) => setIsChecked ( prevState => ! prevState ) }
0 commit comments