Discussion on: ↩️ Native Undo & Redo for the Web

rodneyrehm profile image
Rodney Rehm

Q: This input might confuse accessible user-agents. Please leave me a comment if you have ideas on how to solve this for screen readers etc!

I'd expect adding aria-hidden="true" would complement your efforts to avoid keyboard focus and effectively hide the element from screen readers.

We focus on the undoer, but this is prevented by the event handler we set up initially

That's not quite correct as the element receives focus for a very brief time. For visually abled users shifting focus back to the element that had focus before undoer briefly got it, will likely be unobservable, except maybe for the cursor position to change.

However, for users relying on screen readers this may cause an audible indication of focus having been shifted, even though it was shifted back to where it was before. Things may get worse than that if you're dealing with a situation where "nothing has focus" (document.activeElement === document.body). It's pretty likely that the screen reader's "reading position" follows to the focused element, essentially resetting their whereabouts on every pushNewUndoState().