Skip to content

Commit 3bfcd58

Browse files
committed
fix: dont leak keyboard shorcuts like delete, cut, copy paste in lp to editor if text input slected
1 parent 07171b3 commit 3bfcd58

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/LiveDevelopment/BrowserScripts/LiveDevProtocolRemote.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,19 @@
462462
}
463463

464464
// Check if user is editing text content - if so, allow normal text cut
465-
const activeElement = document.activeElement;
466-
const isEditingText = activeElement &&
467-
activeElement.hasAttribute("contenteditable") &&
468-
activeElement.hasAttribute("data-brackets-id");
465+
// Get the truly active element, even if inside shadow roots
466+
let activeElement = document.activeElement;
467+
468+
const isEditingText = activeElement && (
469+
// Check for standard form input elements
470+
['INPUT', 'TEXTAREA', 'SELECT', 'OPTION'].includes(activeElement.tagName) ||
471+
// Check for contentEditable elements
472+
activeElement.isContentEditable ||
473+
// Check for ARIA roles that indicate text input
474+
['textbox', 'searchbox', 'combobox'].includes(activeElement.getAttribute('role')) ||
475+
// Check if element is designed to receive text input
476+
(activeElement.hasAttribute("contenteditable") && activeElement.hasAttribute("data-brackets-id"))
477+
);
469478
const isInEditMode = window._LD && window._LD.getMode && window._LD.getMode() === 'edit';
470479
// Cut: Ctrl+X / Cmd+X - operates on selected element
471480
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "x") {

0 commit comments

Comments
 (0)