mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-12 17:04:57 +03:00
fix(web-test): use target.y coordinates to find expand icon row
The expand/collapse code re-searched for the target row by first-cell text, which was ambiguous when parent and child rows share the same prefix (e.g. "БУ"). This caused expand to hit the wrong (already- expanded) row and skip. Use target.y from the initial findClickTarget instead — matches the exact row. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2063,17 +2063,16 @@ export async function clickElement(text, { dblclick, table, toggle, expand, modi
|
||||
const grid = gridSel ? document.querySelector(gridSel) : document.querySelector('[id^="' + p + '"].grid');
|
||||
const body = grid?.querySelector('.gridBody');
|
||||
if (!body) return null;
|
||||
const targetY = ${target.y};
|
||||
const lines = [...body.querySelectorAll('.gridLine')];
|
||||
for (const line of lines) {
|
||||
const textBoxes = [...line.querySelectorAll('.gridBoxText')].filter(b => b.offsetWidth > 0);
|
||||
const text = textBoxes[0]?.innerText?.trim() || '';
|
||||
if (text.toLowerCase().replace(/ё/gi, 'е') === ${JSON.stringify(target.name.toLowerCase().replace(/ё/gi, 'е'))}) {
|
||||
const icon = line.querySelector('.gridListH, .gridListV');
|
||||
if (icon) {
|
||||
const r = icon.getBoundingClientRect();
|
||||
const isExpanded = !!icon.classList.contains('gridListV');
|
||||
return { x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2), isExpanded };
|
||||
}
|
||||
const lr = line.getBoundingClientRect();
|
||||
if (targetY < lr.top || targetY > lr.bottom) continue;
|
||||
const icon = line.querySelector('.gridListH, .gridListV');
|
||||
if (icon) {
|
||||
const r = icon.getBoundingClientRect();
|
||||
const isExpanded = !!icon.classList.contains('gridListV');
|
||||
return { x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2), isExpanded };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -2112,18 +2111,17 @@ export async function clickElement(text, { dblclick, table, toggle, expand, modi
|
||||
const grid = gridSel ? document.querySelector(gridSel) : document.querySelector('[id^="' + p + '"].grid');
|
||||
const body = grid?.querySelector('.gridBody');
|
||||
if (!body) return null;
|
||||
const targetY = ${target.y};
|
||||
const lines = [...body.querySelectorAll('.gridLine')];
|
||||
for (const line of lines) {
|
||||
const textBoxes = [...line.querySelectorAll('.gridBoxText')].filter(b => b.offsetWidth > 0);
|
||||
const text = textBoxes[0]?.innerText?.trim() || '';
|
||||
if (text.toLowerCase().replace(/ё/gi, 'е') === ${JSON.stringify(target.name.toLowerCase().replace(/ё/gi, 'е'))}) {
|
||||
const treeIcon = line.querySelector('.gridBoxImg [tree="true"]');
|
||||
if (treeIcon) {
|
||||
const r = treeIcon.getBoundingClientRect();
|
||||
const bg = treeIcon.style.backgroundImage || '';
|
||||
const isExpanded = bg.includes('gx=0');
|
||||
return { x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2), isExpanded };
|
||||
}
|
||||
const lr = line.getBoundingClientRect();
|
||||
if (targetY < lr.top || targetY > lr.bottom) continue;
|
||||
const treeIcon = line.querySelector('.gridBoxImg [tree="true"]');
|
||||
if (treeIcon) {
|
||||
const r = treeIcon.getBoundingClientRect();
|
||||
const bg = treeIcon.style.backgroundImage || '';
|
||||
const isExpanded = bg.includes('gx=0');
|
||||
return { x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2), isExpanded };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user