fix: ignore global hotkeys in editable fields
This commit is contained in:
parent
f112e9a2d0
commit
0e5d13ff01
|
|
@ -1980,6 +1980,7 @@
|
|||
|
||||
function onKeyActivate(fn) {
|
||||
return (e) => {
|
||||
if (isEditableTarget(e.target)) return
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault()
|
||||
fn()
|
||||
|
|
|
|||
|
|
@ -208,6 +208,15 @@ async function runReadyScenario(cdp, url) {
|
|||
|
||||
await clickText(cdp, '.tab', 'Действия')
|
||||
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 assertText(cdp, 'Manual smoke entry', 'worklog: entry visible')
|
||||
|
|
@ -368,6 +377,21 @@ async function setInputValue(cdp, selector, value) {
|
|||
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) {
|
||||
await cdp.send('Runtime.evaluate', {
|
||||
expression: `window.__VERSTAK_GUI_SMOKE_CLIPBOARD__ = ${JSON.stringify(value)}`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue