11import { expect } from '@esm-bundle/chai' ;
2- import { fixtureSync , nextFrame , oneEvent } from '@vaadin/testing-helpers' ;
2+ import { fixtureSync , nextRender , oneEvent } from '@vaadin/testing-helpers' ;
33import { sendKeys } from '@web/test-runner-commands' ;
44import './not-animated-styles.js' ;
55import '@vaadin/accordion' ;
@@ -14,56 +14,58 @@ describe('accordion in dialog', () => {
1414 root . innerHTML = `
1515 <vaadin-accordion>
1616 <vaadin-accordion-panel>
17- <div slot="summary">Panel 1</div>
18- <button>Button 1</button>
17+ <vaadin-accordion-heading slot="summary">Panel 1</vaadin-accordion-heading>
18+ <div>
19+ <input type="text" placeholder="Input 1" />
20+ </div>
1921 </vaadin-accordion-panel>
2022 <vaadin-accordion-panel>
21- <div slot="summary">Panel 2</div >
22- <button>Button 2</button >
23+ <vaadin-accordion-heading slot="summary">Panel 2</vaadin-accordion-heading >
24+ <div>Content 2</div >
2325 </vaadin-accordion-panel>
2426 </vaadin-accordion>
2527 ` ;
2628 } ;
2729 dialog . opened = true ;
2830 overlay = dialog . $ . overlay ;
2931 await oneEvent ( overlay , 'vaadin-overlay-open' ) ;
30- await nextFrame ( ) ;
32+ await nextRender ( ) ;
3133 accordion = overlay . querySelector ( 'vaadin-accordion' ) ;
3234 panels = accordion . items ;
3335 } ) ;
3436
3537 it ( 'should move focus from panel heading to content on Tab' , async ( ) => {
3638 // Focus first panel (opened)
3739 await sendKeys ( { press : 'Tab' } ) ;
38- expect ( document . activeElement ) . to . equal ( panels [ 0 ] ) ;
40+ expect ( document . activeElement ) . to . equal ( panels [ 0 ] . focusElement ) ;
3941
4042 // Move focus to the content
4143 await sendKeys ( { press : 'Tab' } ) ;
42- expect ( document . activeElement ) . to . equal ( panels [ 0 ] . querySelector ( 'button ' ) ) ;
44+ expect ( document . activeElement ) . to . equal ( panels [ 0 ] . querySelector ( 'input ' ) ) ;
4345 } ) ;
4446
4547 it ( 'should move focus from panel content to heading on Shift + Tab' , async ( ) => {
4648 // Focus the first panel content
47- panels [ 0 ] . querySelector ( 'button ' ) . focus ( ) ;
49+ panels [ 0 ] . querySelector ( 'input ' ) . focus ( ) ;
4850
4951 // Move focus back to heading
5052 await sendKeys ( { down : 'Shift' } ) ;
5153 await sendKeys ( { press : 'Tab' } ) ;
5254 await sendKeys ( { up : 'Shift' } ) ;
5355
54- expect ( document . activeElement ) . to . equal ( panels [ 0 ] ) ;
56+ expect ( document . activeElement ) . to . equal ( panels [ 0 ] . focusElement ) ;
5557 } ) ;
5658
5759 it ( 'should skip focusable element in closed panel on Tab' , async ( ) => {
5860 accordion . opened = 1 ;
5961
6062 // Focus first panel (closed)
6163 await sendKeys ( { press : 'Tab' } ) ;
62- expect ( document . activeElement ) . to . equal ( panels [ 0 ] ) ;
64+ expect ( document . activeElement ) . to . equal ( panels [ 0 ] . focusElement ) ;
6365
6466 // Focus second panel (opened)
6567 await sendKeys ( { press : 'Tab' } ) ;
66- expect ( document . activeElement ) . to . equal ( panels [ 1 ] ) ;
68+ expect ( document . activeElement ) . to . equal ( panels [ 1 ] . focusElement ) ;
6769 } ) ;
6870
6971 it ( 'should skip focusable element in closed panel on Shift + Tab' , async ( ) => {
@@ -77,6 +79,6 @@ describe('accordion in dialog', () => {
7779 await sendKeys ( { press : 'Tab' } ) ;
7880 await sendKeys ( { up : 'Shift' } ) ;
7981
80- expect ( document . activeElement ) . to . equal ( panels [ 0 ] ) ;
82+ expect ( document . activeElement ) . to . equal ( panels [ 0 ] . focusElement ) ;
8183 } ) ;
8284} ) ;
0 commit comments