From 0e5ad754e84906771302517e5d19decc735a0c88 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Fri, 29 May 2026 12:12:08 +0300 Subject: [PATCH] =?UTF-8?q?fix(web-test):=20focus-click=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20reveal/scroll=20=D0=BD=D0=B5=20=D0=B4=D0=BE=D0=BB?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=20=D0=B2=D1=85=D0=BE=D0=B4=D0=B8=D1=82=D1=8C?= =?UTF-8?q?=20=D0=B2=20edit-mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit После focus-click перед PageDown (reveal-loop) или ArrowRight/Left (horizontal scroll) клавиатурная навигация ломалась если click попадал в Number/Date ячейку — она автоматически входила в edit-mode, и стрелки начинали навигацию внутри input вместо движения по гриду. Два изменения: 1. findFocusCellScript generic mode (без direction) теперь берёт cells[0] вместо cells.slice(1) — то есть первую видимую колонку. В document tabular sections это типично Reference (Номенклатура), которая не входит в edit-mode по single click. Защиту от tree-toggles оставил точечно: для tree-гридов (presence of .gridBoxTree) пропускаем первую колонку как и раньше. 2. В click-cell.mjs после focus-click в revealAndFindCell и scrollGridToCell добавил тот же isInputFocusedInGrid + Escape страховочный фолбек, что и в deleteTableRow — на случай если focus всё же попал в input. Co-Authored-By: Claude Opus 4.7 --- .claude/skills/web-test/scripts/dom/grid.mjs | 12 +++++++++--- .../web-test/scripts/engine/table/click-cell.mjs | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.claude/skills/web-test/scripts/dom/grid.mjs b/.claude/skills/web-test/scripts/dom/grid.mjs index 72c69827..38a9e22c 100644 --- a/.claude/skills/web-test/scripts/dom/grid.mjs +++ b/.claude/skills/web-test/scripts/dom/grid.mjs @@ -1,4 +1,4 @@ -// web-test dom/grid v1.5 — grid resolution + table reading + edit-time helpers +// web-test dom/grid v1.6 — grid resolution + table reading + edit-time helpers // Source: https://github.com/Nikolay-Shirokov/cc-1c-skills /** @@ -596,12 +596,18 @@ export function findFocusCellScript(gridSelector, { rowIdx, direction } = {}) { visible.sort((a, b) => a.r.x - b.r.x); candidates = direction === 'ArrowRight' ? [...visible].reverse() : visible; } else { - // Generic focus mode: any visible cell past the first column (tree toggles). + // Generic focus mode (used by reveal-loop): pick the FIRST visible cell — + // typically a Reference column (Номенклатура in документах) which doesn't + // auto-enter edit mode on click. Number/Date/String cells auto-edit and + // break subsequent PageDown navigation. + // For tree grids (presence of .gridBoxTree), skip first column to avoid + // toggling expand/collapse of the row. + const isTree = !!body.querySelector('.gridBoxTree'); const cells = [...line.children] .filter(b => b.offsetWidth > 0) .map(b => ({ b, r: b.getBoundingClientRect(), checkbox: !!b.querySelector('.checkbox') })); if (!cells.length) return null; - candidates = cells.length > 1 ? cells.slice(1) : cells; + candidates = isTree && cells.length > 1 ? cells.slice(1) : cells; } const pick = candidates.find(v => !v.checkbox) || candidates[0]; if (!pick) return null; diff --git a/.claude/skills/web-test/scripts/engine/table/click-cell.mjs b/.claude/skills/web-test/scripts/engine/table/click-cell.mjs index 005d0065..b2ad452b 100644 --- a/.claude/skills/web-test/scripts/engine/table/click-cell.mjs +++ b/.claude/skills/web-test/scripts/engine/table/click-cell.mjs @@ -1,4 +1,4 @@ -// web-test table/click-cell v1.1 — click a cell in a form grid by (row, column). +// web-test table/click-cell v1.2 — click a cell in a form grid by (row, column). // Source: https://github.com/Nikolay-Shirokov/cc-1c-skills // // Routed from core/click.mjs when the user calls clickElement({row, column}) and @@ -22,7 +22,7 @@ import { page } from '../core/state.mjs'; import { waitForStable } from '../core/wait.mjs'; -import { modifierClick, returnFormState } from '../core/helpers.mjs'; +import { modifierClick, returnFormState, isInputFocusedInGrid } from '../core/helpers.mjs'; import { scrollHorizontallyByKey } from '../core/scroll-horiz.mjs'; import { findGridCellScript, findFocusCellScript, snapshotGridScript, @@ -115,6 +115,12 @@ async function revealAndFindCell({ formNum, gridSelector, target, scroll }) { if (!focusPt) return { error: 'no_focusable_cell' }; await page.mouse.click(focusPt.x, focusPt.y); await page.waitForTimeout(FOCUS_WAIT_MS); + // Click on a Number/Date cell auto-enters edit mode in 1С; PageDown there + // is a no-op. Exit edit mode before driving the reveal loop. + if (await isInputFocusedInGrid({ gridSelector })) { + await page.keyboard.press('Escape'); + await page.waitForTimeout(150); + } let prevSnap = await page.evaluate(snapshotGridScript(gridSelector)); for (let i = 0; i < limit; i++) { @@ -155,6 +161,12 @@ async function scrollGridToCell({ formNum, gridSelector, target, cell }) { if (!focusPt) throw new Error('clickElement: no visible cell to focus for horizontal scroll'); await page.mouse.click(focusPt.x, focusPt.y); await page.waitForTimeout(FOCUS_WAIT_MS); + // Click on a Number/Date cell auto-enters edit mode in 1С; arrow keys there + // navigate text inside the input rather than scrolling the viewport. Exit first. + if (await isInputFocusedInGrid({ gridSelector })) { + await page.keyboard.press('Escape'); + await page.waitForTimeout(150); + } await scrollHorizontallyByKey({ page,