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,