Current section
Files
Jump to
Current section
Files
priv/cursor-spike/focus2.mjs
import { chromium } from 'playwright';
const b = await chromium.launch(); const p = await (await b.newContext()).newPage();
await p.goto('http://127.0.0.1:4126/');
await p.waitForFunction(()=>document.querySelector('[data-phx-main]')?.classList.contains('phx-connected'),null,{timeout:8000});
await p.waitForTimeout(200);
// focus charlie directly
await p.evaluate(()=>document.querySelector('[data-item="charlie"]').focus());
console.log('before: active=', await p.evaluate(()=>({id:document.activeElement?.id, tag:document.activeElement?.tagName})));
// content patch via synthetic click
await p.evaluate(()=>document.getElementById('c-content').click());
await p.waitForFunction(()=>document.querySelector('[data-item="charlie"]')?.textContent.includes('v1'),null,{timeout:6000});
await p.waitForTimeout(150);
console.log('after content patch: active=', await p.evaluate(()=>({id:document.activeElement?.id, tag:document.activeElement?.tagName})));
console.log('charlie node still focusable, tabindex=', await p.evaluate(()=>document.querySelector('[data-item="charlie"]')?.getAttribute('tabindex')));
// try WITHOUT the Cursor hook re-projecting: focus charlie, check if hook updated() ran
console.log('cursorLog tail:', await p.evaluate(()=>window.__cursorLog.slice(-4)));
await b.close();