@@ -108,6 +108,10 @@ const observeDOM = (function () {
108108 } ;
109109} ) ( ) ;
110110
111+ async function tick ( ) {
112+ return await new Promise < void > ( ( resolve ) => setTimeout ( ( ) => resolve ( ) ) ) ;
113+ }
114+
111115export class Virtual implements ScreenReader {
112116 #activeNode: AccessibilityNode | null = null ;
113117 #container: Node | null = null ;
@@ -256,6 +260,7 @@ export class Virtual implements ScreenReader {
256260 */
257261 async previous ( ) {
258262 this . #checkContainer( ) ;
263+ await tick ( ) ;
259264
260265 const tree = this . #getAccessibilityTree( ) ;
261266
@@ -277,6 +282,7 @@ export class Virtual implements ScreenReader {
277282 */
278283 async next ( ) {
279284 this . #checkContainer( ) ;
285+ await tick ( ) ;
280286
281287 const tree = this . #getAccessibilityTree( ) ;
282288
@@ -301,6 +307,7 @@ export class Virtual implements ScreenReader {
301307 */
302308 async act ( ) {
303309 this . #checkContainer( ) ;
310+ await tick ( ) ;
304311
305312 if ( ! this . #activeNode) {
306313 return ;
@@ -360,6 +367,7 @@ export class Virtual implements ScreenReader {
360367 */
361368 async press ( key : string ) {
362369 this . #checkContainer( ) ;
370+ await tick ( ) ;
363371
364372 if ( ! this . #activeNode) {
365373 return ;
@@ -406,6 +414,7 @@ export class Virtual implements ScreenReader {
406414 */
407415 async type ( text : string ) {
408416 this . #checkContainer( ) ;
417+ await tick ( ) ;
409418
410419 if ( ! this . #activeNode) {
411420 return ;
@@ -424,6 +433,7 @@ export class Virtual implements ScreenReader {
424433 */
425434 async perform ( ) {
426435 this . #checkContainer( ) ;
436+ await tick ( ) ;
427437
428438 // TODO: decide what this means as there is no established "common" command
429439 // set for different screen readers.
@@ -438,6 +448,7 @@ export class Virtual implements ScreenReader {
438448 */
439449 async click ( { button = "left" , clickCount = 1 } = { } ) {
440450 this . #checkContainer( ) ;
451+ await tick ( ) ;
441452
442453 if ( ! this . #activeNode) {
443454 return ;
0 commit comments