From cad9cd057fed38c2bc50e59881c3dfc0a7f7b283 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Mon, 16 Nov 2026 11:40:13 -0600 Subject: [PATCH] fix(webui): sp17 shots, the path reads right at 390 and in both modes: a step link lands with the title and the Save under it both in view (at 390 Save was below the fold), a Save with nothing to save is drawn off rather than in the action colour, and after Save the focus stays in the form it was saved from so the line saying Saved stays in view (at 390 the jump to the graph node put it off screen); the three-clicks test checks the title, Save and the Saved line are in view and the focus is kept (red before: Save in view at 390, and the focus and Saved line on three of four cases) (#1873, lane sp17-workflow-clicks) --- packages/webui/src/public/workflows.css | 2 ++ packages/webui/src/public/workflows.js | 13 +++++++++---- packages/webui/tests/workflows-browser.test.mjs | 7 +++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/webui/src/public/workflows.css b/packages/webui/src/public/workflows.css index a8c1657ff..f3ec8867b 100644 --- a/packages/webui/src/public/workflows.css +++ b/packages/webui/src/public/workflows.css @@ -67,6 +67,8 @@ html[data-organizations] :is(.wfg-bar,.wfg-step-acts,.wfg-form,.wfg-new) .ws-btn{min-height:32px} html[data-organizations] :is(.wfg-bar,.wfg-form) .ws-btn.primary{background:var(--action);color:var(--onAction);border-color:var(--action)} html[data-organizations] :is(.wfg-bar,.wfg-form) .ws-btn.primary:hover:not(:disabled){background:color-mix(in srgb,var(--action) 88%,var(--strong))} +/* SP17 shots: a Save with nothing to save reads as off, not as the action colour. */ +html[data-organizations] :is(.wfg-bar,.wfg-form) .ws-btn.primary:disabled{background:var(--raised);color:var(--muted);border-color:var(--line)} html[data-organizations] :is(.wfg-bar,.wfg-step-acts) .ws-btn.danger{color:var(--danger)} html[data-organizations] :is(.wfg-bar,.wfg-step-acts,.wfg-form,.wfg-new) .ws-btn:focus-visible{outline:2px solid var(--focus);outline-offset:2px} .wfg-bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 0 10px} diff --git a/packages/webui/src/public/workflows.js b/packages/webui/src/public/workflows.js index 71a0b762c..d10003a30 100644 --- a/packages/webui/src/public/workflows.js +++ b/packages/webui/src/public/workflows.js @@ -618,7 +618,9 @@ drafts.delete(key); notes.set(key, `Saved ${name}.`); say(`Saved ${name}.`); - paint(selected() ? `wfg-step:${selected()}` : 'wfg-delete'); + // Focus stays in the form it was saved from, so the line saying Saved stays in view (at 390 a jump to the + // graph node put it below the fold). + paint(selected() ? 'wfg-f-title' : 'wfg-m-title'); } catch (error) { d.busy = false; d.status = kept[error.code] ?? `Not saved: ${error.message} Your change is kept.`; @@ -755,11 +757,14 @@ const want = landing; landing = null; if (!want || location.hash !== want) return false; - const f = stepFormEl()?.elements.title; + const form = stepFormEl(), f = form?.elements.title; if (!f) return false; - f.focus(); + // The title and the Save under it both in view (at 390 Save was below the fold), the title winning on a short screen. + f.focus({ preventScroll: true }); + form.querySelector('[data-wfg-save]')?.scrollIntoView({ block: 'nearest' }); + f.scrollIntoView({ block: 'nearest' }); f.setSelectionRange(f.value.length, f.value.length); - say(`Step ${Number(stepFormEl().dataset.wfgStepForm) + 1}, ${f.value}. Change it and press Save.`); + say(`Step ${Number(form.dataset.wfgStepForm) + 1}, ${f.value}. Change it and press Save.`); return true; } document.addEventListener('click', ev => { diff --git a/packages/webui/tests/workflows-browser.test.mjs b/packages/webui/tests/workflows-browser.test.mjs index a8971908d..7ada9cf0f 100644 --- a/packages/webui/tests/workflows-browser.test.mjs +++ b/packages/webui/tests/workflows-browser.test.mjs @@ -818,10 +818,17 @@ test('SP17: one field of one step changes and saves in three clicks', { timeout: // The step's title field has focus, the caret at the end, ready to type. await wait(`document.activeElement?.matches('[data-wfg-step-form] input[name="title"]') && document.activeElement.value === 'Ship'`, 'focus in the title'); assert.equal(await b.evaluate(`document.activeElement.selectionStart`), 4); + // The title and Save are both on screen without a scroll (SP17 shots: at 390 Save was below the fold). + const inView = sel => `(()=>{const r=document.querySelector(${JSON.stringify(sel)}).getBoundingClientRect();return r.top>=0&&r.bottom<=innerHeight})()`; + assert.equal(await b.evaluate(inView('[data-wfg-step-form] input[name="title"]')), true, 'title in view'); + assert.equal(await b.evaluate(inView('[data-wfg-step-form] [data-wfg-save]')), true, 'Save in view'); assert.match(await b.evaluate(`document.getElementById('announce')?.textContent ?? ''`), /Step 2, Ship\. Change it and press Save\./); await b.call('Input.insertText', { text: ' the release' }); await click('[data-wfg-step-form] [data-wfg-save]', 'Save'); await wait(`/Saved change\\./.test(${text('[data-wfg-status]')}) && !document.querySelector('[data-wfg-unsaved]')`, 'saved'); + // Focus stays in the step's title, and the line saying it saved is on screen. + await wait(`document.activeElement?.dataset.focusKey === 'wfg-f-title'`, 'focus kept in the form'); + assert.equal(await b.evaluate(inView('[data-wfg-step-form] [data-wfg-status]')), true, 'Saved line in view'); const clicks = await b.evaluate(`__clicks`); assert.equal(clicks.length, c.want.length, `${c.want.length} clicks: ${JSON.stringify(clicks)}`); c.want.forEach((w, i) => (w instanceof RegExp ? assert.match(clicks[i], w) : assert.equal(clicks[i], w)));