@@ -36,7 +36,7 @@ describe('Quill', () => {
36
36
} ) ;
37
37
38
38
test ( 'register(path, target)' , ( ) => {
39
- class Counter { }
39
+ class Counter { }
40
40
Quill . register ( 'modules/counter' , Counter ) ;
41
41
42
42
expect ( Quill . imports ) . toHaveProperty ( 'modules/counter' , Counter ) ;
@@ -59,7 +59,7 @@ describe('Quill', () => {
59
59
static blotName = 'a-blot' ;
60
60
static className = 'ql-a-blot' ;
61
61
}
62
- class AModule { }
62
+ class AModule { }
63
63
Quill . register ( {
64
64
'formats/a-blot' : ABlot ,
65
65
'modules/a-module' : AModule ,
@@ -833,7 +833,7 @@ describe('Quill', () => {
833
833
} ) ;
834
834
835
835
test ( 'toolbar custom handler, default container' , ( ) => {
836
- const handler = ( ) => { } ; // eslint-disable-line func-style
836
+ const handler = ( ) => { } ; // eslint-disable-line func-style
837
837
const config = expandConfig ( `#${ testContainerId } ` , {
838
838
modules : {
839
839
toolbar : {
@@ -1201,7 +1201,7 @@ describe('Quill', () => {
1201
1201
observer . observe ( element ) ;
1202
1202
// Firefox doesn't call IntersectionObserver callback unless
1203
1203
// there are rafs.
1204
- requestAnimationFrame ( ( ) => { } ) ;
1204
+ requestAnimationFrame ( ( ) => { } ) ;
1205
1205
} ) ;
1206
1206
} ;
1207
1207
@@ -1377,4 +1377,54 @@ describe('Quill', () => {
1377
1377
) . toEqual ( 0 ) ;
1378
1378
} ) ;
1379
1379
} ) ;
1380
+
1381
+ describe ( 'accessibility' , ( ) => {
1382
+ describe ( 'toolbar' , ( ) => {
1383
+ test ( 'tabbing - no roving tabindex' , ( ) => {
1384
+ const container = createContainer ( '<div></div>' ) ;
1385
+ new Quill ( container , {
1386
+ modules : {
1387
+ toolbar : [ [ 'bold' , 'italic' ] , [ 'link' , 'image' ] ] ,
1388
+ } ,
1389
+ } ) ;
1390
+ const toolbar = container ?. parentElement ?. querySelector ( '.ql-toolbar' ) ;
1391
+ const buttons = toolbar ?. querySelectorAll ( 'button' ) ;
1392
+ if ( ! buttons ) {
1393
+ throw new Error ( 'No buttons found' ) ;
1394
+ }
1395
+ expect ( buttons . length ) . toBe ( 4 ) ;
1396
+
1397
+ buttons . forEach ( ( button ) => {
1398
+ expect ( button . getAttribute ( 'tabindex' ) ) . toBe ( null ) ;
1399
+ } ) ;
1400
+ } ) ;
1401
+
1402
+ test ( 'tabbing - roving tabindex' , ( ) => {
1403
+ const container = createContainer ( '<div></div>' ) ;
1404
+ if ( ! container . parentElement ) {
1405
+ throw new Error ( 'No parent element found' ) ;
1406
+ }
1407
+ container . parentElement . classList . add ( 'roving-tabindex' ) ;
1408
+ new Quill ( container , {
1409
+ modules : {
1410
+ toolbar : [ [ 'bold' , 'italic' ] , [ 'link' , 'image' ] ] ,
1411
+ } ,
1412
+ } ) ;
1413
+ const toolbar = container ?. parentElement ?. querySelector ( '.ql-toolbar' ) ;
1414
+ const buttons = toolbar ?. querySelectorAll ( 'button' ) ;
1415
+ if ( ! buttons ) {
1416
+ throw new Error ( 'No buttons found' ) ;
1417
+ }
1418
+ expect ( buttons . length ) . toBe ( 4 ) ;
1419
+
1420
+ buttons . forEach ( ( button , key ) => {
1421
+ if ( key === 0 ) {
1422
+ expect ( button . getAttribute ( 'tabindex' ) ) . toBe ( '0' ) ;
1423
+ } else {
1424
+ expect ( button . getAttribute ( 'tabindex' ) ) . toBe ( '-1' ) ;
1425
+ }
1426
+ } ) ;
1427
+ } ) ;
1428
+ } ) ;
1429
+ } ) ;
1380
1430
} ) ;
0 commit comments