Repository navigation
fix(app): give focus back when ⌘W closes the side panel's last New tab - #60435
Conversation
There was a problem hiding this comment.
The fix is sound and works. On the base, the target e2e fails at the first ⌘W because the panel closes. I also ran this PR's version of the test against the base's source, and it fails because the composer doesn't get focus back, so the panels.tsx change is what makes it pass. With the PR, all of tabs.spec.ts and side-panels.spec.ts pass locally on headless Chromium (46 tests), and tsc -b is clean.
One behaviour change to be aware of: emptied() now also gives focus back when ⌘W closes the panel's last real tab, so focus returns to where the panel was opened from (e.g. the composer) rather than to the toggle. That matches closing with the toggle, and the existing tests still pass.
Public API: unchanged.
#60126 made closing a strip's last New tab close the side region, as closing its last tab does. #59002 assumed the panel stayed open after that press and then refocused the closed panel, so its e2e failed on dev. The region now gives focus back to where it was opened from whenever emptying it closes it, and ⌘W only keeps focus in the panel while it is still open. The e2e expectation is updated to #60126's intended behaviour: the first ⌘W closes the New tab with the panel, the next press closes nothing, and only then does ⌘W close the session tab.
ffaf1d7 to
c1c15af
Compare
There was a problem hiding this comment.
The new commits only rebase this onto the current dev. The change itself is the same as before; the only difference is the base's new empty() check around the emptied() call in panels.tsx. I re-checked it on the new base: the target e2e still fails at the first ⌘W. With this PR, all of tabs.spec.ts and side-panels.spec.ts pass locally on headless Chromium (46 tests), and tsc -b is clean.
Public API: unchanged.
Fixes dev-red e2e
tabs.spec.ts"⌘W in the side panel closes its New tab, then the panel, and only then the session tab" (Linux and Windows, app-2) after #59002.What broke: the first ⌘W in a side panel holding only a New tab closed the panel too, but the test expected it to stay open.
Cause: #60126 landed after #59002's CI base and made closing a strip's last New tab close the side region, on purpose and covered by its own e2e. #59002 assumed the panel stayed open after that press, and afterwards refocused the panel even though it was now closed.
Fix:
Read:
tabs.spec.tsandside-panels.spec.tson mini: the target test passes. 5 tests in tabs.spec.ts that don't touch the side panel also failed there (tab-cycling and paste shortcuts, which behave differently on macOS); CI's Linux and Windows runs are the real check.bun typecheckandlint:changedare clean.