Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,21 @@ describe('useNativeChatComposerRevealFocus', () => {
outside.remove()
})

it('claims focus from the composer of the chat tab hidden by the same switch', () => {
const hiddenPane = document.createElement('div')
const previousComposer = document.createElement('textarea')
hiddenPane.appendChild(previousComposer)
document.body.appendChild(hiddenPane)
previousComposer.focus()
render({ isVisible: false, isFocusedGroup: true })
// Chromium leaves focus on the hidden field until a later task, after the reveal claim runs.
hiddenPane.setAttribute('inert', '')
render({ isVisible: true, isFocusedGroup: true })
drainFrames()
expect(container.querySelector('textarea')).toBe(document.activeElement)
hiddenPane.remove()
})

it('still claims focus from the covered xterm helper textarea', () => {
const helper = document.createElement('textarea')
helper.className = 'xterm-helper-textarea'
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/src/components/terminal-pane/pane-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export function shouldPreserveEditableFocus(element: Element | null): boolean {
if (element.classList.contains('xterm-helper-textarea') || element.closest('.xterm')) {
return false
}
// Why: a field in a just-hidden pane keeps focus until Chromium drops it to body a task later.
if (element.closest('[hidden], [inert]')) {
return false
}
// Why: deferred fit/focus work can run after inline rename or settings
// fields take focus. Layout maintenance must not blur user edits closed.
return (
Expand Down
Loading