fix: ignore global hotkeys in editable fields

This commit is contained in:
mirivlad 2026-06-05 07:47:07 +08:00
parent f112e9a2d0
commit 0e5d13ff01
2 changed files with 25 additions and 0 deletions

View File

@ -1980,6 +1980,7 @@
function onKeyActivate(fn) { function onKeyActivate(fn) {
return (e) => { return (e) => {
if (isEditableTarget(e.target)) return
if (e.key === 'Enter' || e.key === ' ') { if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault() e.preventDefault()
fn() fn()

View File

@ -208,6 +208,15 @@ async function runReadyScenario(cdp, url) {
await clickText(cdp, '.tab', 'Действия') await clickText(cdp, '.tab', 'Действия')
await assertText(cdp, 'Deploy smoke', 'actions: action card visible') await assertText(cdp, 'Deploy smoke', 'actions: action card visible')
await clickText(cdp, '.actions-tab .btn', 'Добавить действие')
await waitForSelector(cdp, '.modal input[type="text"]')
await dispatchKeydown(cdp, '.modal input[type="text"]', ' ')
await assertEval(cdp, `!!document.querySelector('.modal input[type="text"]')`, 'actions: space in title input keeps modal open')
await setInputValue(cdp, '.modal input[type="text"]', 'GUI smoke action with spaces')
await setInputValue(cdp, '.modal input[placeholder="https://example.com"]', 'https://example.test/action')
await clickText(cdp, '.modal-actions .btn', 'Создать')
await waitForGone(cdp, '.modal-overlay')
await assertText(cdp, 'GUI smoke action with spaces', 'actions: action with spaces saved')
await clickText(cdp, '.tab', 'Журнал') await clickText(cdp, '.tab', 'Журнал')
await assertText(cdp, 'Manual smoke entry', 'worklog: entry visible') await assertText(cdp, 'Manual smoke entry', 'worklog: entry visible')
@ -368,6 +377,21 @@ async function setInputValue(cdp, selector, value) {
await sleep(100) await sleep(100)
} }
async function dispatchKeydown(cdp, selector, key) {
const ok = await evalValue(cdp, `
(() => {
const el = document.querySelector(${JSON.stringify(selector)});
if (!el) return false;
el.focus();
const event = new KeyboardEvent('keydown', { key: ${JSON.stringify(key)}, bubbles: true, cancelable: true });
el.dispatchEvent(event);
return true;
})()
`)
if (!ok) throw new Error(`Keydown target not found: ${selector}`)
await sleep(100)
}
async function setClipboardText(cdp, value) { async function setClipboardText(cdp, value) {
await cdp.send('Runtime.evaluate', { await cdp.send('Runtime.evaluate', {
expression: `window.__VERSTAK_GUI_SMOKE_CLIPBOARD__ = ${JSON.stringify(value)}`, expression: `window.__VERSTAK_GUI_SMOKE_CLIPBOARD__ = ${JSON.stringify(value)}`,