mirror of
https://github.com/stablyai/orca.git
synced 2026-09-25 16:02:38 +00:00
Fix editor copy when Browser split is open (#2195)
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user