NVDA and document.activeElement value when using buttons inside grids

Viewed 16

I have a grid with role="grid" (also tried role="table"). There are buttons in the grid that open dialogs (v-dialog). Before opening, I save the last focused element with

this.lastFocus = (document.activeElement || document.body)

And upon closing the dialog, I restore focus to the initiating button with

if (document.body.contains(this.lastFocus)) this.$nextTick(() => this.lastFocus.focus())

The problem is that this works only if NVDA is not running or I manually switch it to browse mode using Insert+Spacebar before I press Enter on the button. If I just Tab to the button and press Enter, lastFocus will contain the <body> element and not the <button> clicked last.

0 Answers
Related