Merge branch 'dev'

This commit is contained in:
Nick Shirokov
2026-03-14 18:10:41 +03:00
2 changed files with 32 additions and 25 deletions
+2 -1
View File
@@ -1560,7 +1560,8 @@ export async function clickElement(text, { dblclick, table } = {}) {
// Tree node: click the tree expand/collapse icon [tree="true"] for toggle // Tree node: click the tree expand/collapse icon [tree="true"] for toggle
const treeIconCoords = await page.evaluate(`(() => { const treeIconCoords = await page.evaluate(`(() => {
const p = ${JSON.stringify(`form${formNum}_`)}; const p = ${JSON.stringify(`form${formNum}_`)};
const grid = document.querySelector('[id^="' + p + '"].grid'); const gridSel = ${JSON.stringify(target.gridId ? '#' + target.gridId : null)};
const grid = gridSel ? document.querySelector(gridSel) : document.querySelector('[id^="' + p + '"].grid');
const body = grid?.querySelector('.gridBody'); const body = grid?.querySelector('.gridBody');
if (!body) return null; if (!body) return null;
const lines = [...body.querySelectorAll('.gridLine')]; const lines = [...body.querySelectorAll('.gridLine')];
+11 -5
View File
@@ -685,10 +685,17 @@ export function findClickTargetScript(formNum, text, { tableName, gridSelector }
} }
// Grid rows — fallback: search in table rows (for hierarchical/tree navigation) // Grid rows — fallback: search in table rows (for hierarchical/tree navigation)
const grid = document.querySelector('[id^="' + p + '"].grid'); // Search ALL visible grids (or specific grid when table parameter is set)
if (grid) { let grids;
if (gridSelector) {
const g = document.querySelector(gridSelector);
grids = g ? [g] : [];
} else {
grids = [...document.querySelectorAll('[id^="' + p + '"].grid')].filter(g => g.offsetWidth > 0);
}
for (const grid of grids) {
const body = grid.querySelector('.gridBody'); const body = grid.querySelector('.gridBody');
if (body) { if (!body) continue;
const lines = [...body.querySelectorAll('.gridLine')]; const lines = [...body.querySelectorAll('.gridLine')];
for (const line of lines) { for (const line of lines) {
const textBoxes = [...line.querySelectorAll('.gridBoxText')].filter(b => b.offsetWidth > 0); const textBoxes = [...line.querySelectorAll('.gridBoxText')].filter(b => b.offsetWidth > 0);
@@ -707,12 +714,11 @@ export function findClickTargetScript(formNum, text, { tableName, gridSelector }
else if (isTreeNode && hasChildren) kind = 'gridTreeNode'; else if (isTreeNode && hasChildren) kind = 'gridTreeNode';
else kind = 'gridRow'; else kind = 'gridRow';
const r = line.getBoundingClientRect(); const r = line.getBoundingClientRect();
return { id: '', kind, name: rowTexts[0] || '', return { id: '', kind, name: rowTexts[0] || '', gridId: grid.id,
x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2) }; x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2) };
} }
} }
} }
}
return { error: 'not_found', available: items.map(i => i.name).filter(Boolean) }; return { error: 'not_found', available: items.map(i => i.name).filter(Boolean) };
})()`; })()`;