@@ -30,10 +30,17 @@ type TestDashboardItem = DashboardItem & { id: number };
3030describe ( 'dashboard - keyboard interaction' , ( ) => {
3131 let dashboard : Dashboard < TestDashboardItem > ;
3232 let keydownSpy ;
33+ let firstGlobalFocusable : HTMLElement ;
3334 const columnWidth = 200 ;
3435
3536 beforeEach ( async ( ) => {
36- dashboard = fixtureSync ( '<vaadin-dashboard></vaadin-dashboard>' ) ;
37+ [ firstGlobalFocusable , dashboard ] = fixtureSync (
38+ `<div>
39+ <input id="first-global-focusable" />
40+ <vaadin-dashboard></vaadin-dashboard>
41+ </div>` ,
42+ ) . children as unknown as [ HTMLElement , Dashboard < TestDashboardItem > ] ;
43+ firstGlobalFocusable . focus ( ) ;
3744 await nextFrame ( ) ;
3845 dashboard . editable = true ;
3946 keydownSpy = sinon . spy ( ) ;
@@ -56,15 +63,6 @@ describe('dashboard - keyboard interaction', () => {
5663
5764 dashboard . style . width = `${ columnWidth * 2 } px` ;
5865 await nextResize ( dashboard ) ;
59-
60- // Make sure the following tab goes back to the first widget (needed for Firefox)
61- const widget = getElementFromCell ( dashboard , 0 , 0 ) ! ;
62- widget . focus ( ) ;
63- await nextFrame ( ) ;
64- await sendKeys ( { down : 'Shift' } ) ;
65- await sendKeys ( { press : 'Tab' } ) ;
66- await sendKeys ( { up : 'Shift' } ) ;
67- await nextFrame ( ) ;
6866 } ) ;
6967
7068 it ( 'should focus the widget' , async ( ) => {
@@ -111,9 +109,9 @@ describe('dashboard - keyboard interaction', () => {
111109 expect ( spy . firstCall . args [ 0 ] . detail ) . to . eql ( { item : { id : 0 } , value : true } ) ;
112110 } ) ;
113111
114- ( isChrome || isFirefox ? it : it . skip ) ( 'should not remove the widget on backspace ' , async ( ) => {
112+ ( isChrome || isFirefox ? it : it . skip ) ( 'should not remove the widget on Delete ' , async ( ) => {
115113 await sendKeys ( { press : 'Tab' } ) ;
116- await sendKeys ( { press : 'Backspace ' } ) ;
114+ await sendKeys ( { press : 'Delete ' } ) ;
117115 expect ( dashboard . items ) . to . eql ( [ { id : 0 } , { id : 1 } , { items : [ { id : 2 } , { id : 3 } ] } ] ) ;
118116 } ) ;
119117
@@ -183,8 +181,8 @@ describe('dashboard - keyboard interaction', () => {
183181 expect ( widget . hasAttribute ( 'focused' ) ) . to . be . false ;
184182 } ) ;
185183
186- it ( 'should remove the widget on backspace ' , async ( ) => {
187- await sendKeys ( { press : 'Backspace ' } ) ;
184+ it ( 'should remove the widget on Delete ' , async ( ) => {
185+ await sendKeys ( { press : 'Delete ' } ) ;
188186 expect ( dashboard . items ) . to . eql ( [ { id : 1 } , { items : [ { id : 2 } , { id : 3 } ] } ] ) ;
189187 } ) ;
190188
@@ -193,10 +191,10 @@ describe('dashboard - keyboard interaction', () => {
193191 expect ( dashboard . items ) . to . eql ( [ { id : 1 } , { items : [ { id : 2 } , { id : 3 } ] } ] ) ;
194192 } ) ;
195193
196- it ( 'should dispatch an item removed event on backspace ' , async ( ) => {
194+ it ( 'should dispatch an item removed event on Delete ' , async ( ) => {
197195 const spy = sinon . spy ( ) ;
198196 dashboard . addEventListener ( 'dashboard-item-removed' , spy ) ;
199- await sendKeys ( { press : 'Backspace ' } ) ;
197+ await sendKeys ( { press : 'Delete ' } ) ;
200198 expect ( spy . calledOnce ) . to . be . true ;
201199 expect ( spy . firstCall . args [ 0 ] . detail . item ) . to . eql ( { id : 0 } ) ;
202200 expect ( spy . firstCall . args [ 0 ] . detail . items ) . to . eql ( dashboard . items ) ;
@@ -288,9 +286,9 @@ describe('dashboard - keyboard interaction', () => {
288286 expect ( dashboard . items ) . to . eql ( [ { id : 0 } , { id : 1 } , { items : [ { id : 2 } , { id : 3 } ] } ] ) ;
289287 } ) ;
290288
291- it ( 'should cancel the default action on backspace ' , async ( ) => {
289+ it ( 'should cancel the default action on Delete ' , async ( ) => {
292290 keydownSpy . resetHistory ( ) ;
293- await sendKeys ( { press : 'Backspace ' } ) ;
291+ await sendKeys ( { press : 'Delete ' } ) ;
294292 expect ( keydownSpy . firstCall . args [ 0 ] . defaultPrevented ) . to . be . true ;
295293 } ) ;
296294
0 commit comments