Okay, so this is frustrating to test, I do use keyboard navigation a lot, but more so the custom navigation j/k, etc. I rarely tab, as pressing ‘c’ to create a topic is faster than tabbing to the New Topic button.
Where the focus gets placed after a keyboard shortcut is used is far more important to me than where I land once it is over.
So without further ado, Youtube and Facebook both place focus at the top of the DOM when a modal window is closed. FYI, tabbing is Facebook sucks. It first takes you through the long menu on the left, then the ads on the right, then finally your news feed. I opened an image, which opened in a modal, pressed ESC, and hit tab again, only to find myself having to tab through the long list and ads all over again.
Youtube was similar. It started from the top and when I got to the Share feature (“Add To”), I pressed enter and opened up the modal window, I immediately hit ESC and then tabbed again, starting back at the top.
Is it ideal? No. But the alternative is very hacky to me. As you’d have to send the sender to the modal so it knows where to place focus after the modal is closed. However, that is also cumbersome, because I may have tabbed to a link in a post, but used the shortcut ‘!’ to initiate the flag modal for the given selected post. Therefore the focus would go back to the flag icon instead of the link I was actually on (see how it gets hackish?).
Can it be done? Sure. Is it worth the effort when just about every site sucks at it? Probably not.