@@ -181,6 +181,15 @@ export class Checkbox implements ComponentInterface {
181181 this . ionBlur . emit ( ) ;
182182 } ;
183183
184+ private onKeyDown = ( ev : KeyboardEvent ) => {
185+ if ( ev . key === ' ' || ev . key === 'Enter' ) {
186+ ev . preventDefault ( ) ;
187+ if ( ! this . disabled ) {
188+ this . toggleChecked ( ev ) ;
189+ }
190+ }
191+ } ;
192+
184193 private onClick = ( ev : MouseEvent ) => {
185194 if ( this . disabled ) {
186195 return ;
@@ -259,6 +268,10 @@ export class Checkbox implements ComponentInterface {
259268 aria-checked = { indeterminate ? 'mixed' : `${ checked } ` }
260269 aria-describedby = { this . getHintTextID ( ) }
261270 aria-invalid = { this . getHintTextID ( ) === this . errorTextId }
271+ aria-labelledby = { inputId + '-lbl' }
272+ aria-disabled = { disabled ? 'true' : null }
273+ tabindex = "0"
274+ onKeyDown = { this . onKeyDown }
262275 class = { createColorClasses ( color , {
263276 [ mode ] : true ,
264277 'in-item' : hostContext ( 'ion-item' , el ) ,
@@ -272,13 +285,15 @@ export class Checkbox implements ComponentInterface {
272285 } ) }
273286 onClick = { this . onClick }
274287 >
275- < label class = "checkbox-wrapper" >
288+ < label class = "checkbox-wrapper" htmlFor = { inputId } >
276289 { /*
277290 The native control must be rendered
278291 before the visible label text due to https://bugs.webkit.org/show_bug.cgi?id=251951
279292 */ }
280293 < input
281294 type = "checkbox"
295+ aria-hidden = "true"
296+ tabindex = "-1"
282297 checked = { checked ? true : undefined }
283298 disabled = { disabled }
284299 id = { inputId }
@@ -295,6 +310,7 @@ export class Checkbox implements ComponentInterface {
295310 'label-text-wrapper-hidden' : el . textContent === '' ,
296311 } }
297312 part = "label"
313+ id = { inputId + '-lbl' }
298314 >
299315 < slot > </ slot >
300316 { this . renderHintText ( ) }
0 commit comments