Fix editor copy when Browser split is open (#2195)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo Hong
2026-05-17 19:17:19 -07:00
committed by GitHub
co-authored by Orca
parent 077a360e52
commit 8057cbdf78
2 changed files with 23 additions and 6 deletions
@@ -18,6 +18,14 @@ describe('isEditableKeyboardTarget', () => {
expect(isEditableKeyboardTarget(child)).toBe(true)
})
it('returns true for Monaco editor descendants', () => {
const child = {
isContentEditable: false,
closest: (selector: string) => (selector.includes('.monaco-editor') ? {} : null)
}
expect(isEditableKeyboardTarget(child)).toBe(true)
})
it('returns false for non-editable elements', () => {
const div = {
isContentEditable: false,
@@ -12,12 +12,21 @@ export function isEditableKeyboardTarget(target: EventTarget | EditableTargetLik
return false
}
// Why: grab-mode single-key shortcuts should never fire while the user is
// typing into the browser chrome itself (address bar/search fields) or any
// other editable control. Treat nested elements inside those controls as
// editable too so composition wrappers or icons inside the input don't cause
// C/S to be swallowed unexpectedly.
const editableHost = element.closest?.('input, textarea, [contenteditable="true"]')
// Why: Browser panes stay mounted beside editor splits, so their global
// shortcut listeners must treat editor surfaces as editable too.
const editableHost = element.closest?.(
[
'input',
'textarea',
'select',
'[contenteditable=""]',
'[contenteditable="true"]',
'.monaco-editor',
'.diff-editor',
'.rich-markdown-editor',
'.rich-markdown-editor-shell'
].join(', ')
)
if (editableHost) {
return true
}