Tabkeys 2.3.13: a minor tweak
I hadn’t realized it, but a user clued me in to this: In Safari 5.1, Apple has made the browser smarter about which tab to activate when you close the active tab. I’ve added a new option in Tabkeys to take advantage of this fact.
Before version 5.1, Safari would always activate (focus) the tab to the right of the one you were closing—unless, of course, there was no tab to its right, in which case it would by necessity focus the tab to the left of the closing one.
The new behavior in Safari 5.1 is a little more complicated, and to understand it you also have to know about Safari’s new policy for positioning tabs that are created by opening links in new tabs. The two policies work hand in hand.
I think I mentioned the new tab positioning policy in a previous post, but briefly: When opening a link in a new tab, instead of always placing the new tab after all other tabs (as older Safari versions did), Safari 5.1 does this: For the first link you open in a new tab from the current tab, it puts the new tab next to the current tab, on the right. Then, for each subsequent link you open in a new tab from the same tab, it puts that new tab next to the previous new tab.
We can think of these related tabs as a family, consisting of one parent tab—the tab that has these links that you’re opening in new tabs—and at least one child tab—a tab created by opening a link from the parent tab in a new tab. By the way, tab families can be hierarchical—a child tab can itself become a parent tab and have its own children.
Now, back to the question of which tab gets the focus when you close a tab. It turns out that Safari 5.1 acts just like previous versions in this regard, except when you’re closing a tab that belongs to a family. When you close such a tab, what gets the focus is the next tab in the same immediate family. In some cases, that will be the tab to the right of the one being closed. But if there is no sibling tab to the right of the closing tab, Safari will instead focus the sibling tab to the left. And if there are no more sibling tabs, Safari will focus the parent tab. Finally, when you close that tab—assuming it isn’t itself a child in another family—Safari will follow the old tab focusing rules.
The new option in Tabkeys is simply an option to let Safari decide which tab to focus when you close a tab. Previously, the only two options were to focus the left tab or the right tab. Before Safari 5.1, this was enough. But now there needs to be a third option, to let Safari decide. So that’s what’s new.

