diff --git a/e2e/docx-track.spec.ts b/e2e/docx-track.spec.ts index 7d3788b..8c46d1a 100644 --- a/e2e/docx-track.spec.ts +++ b/e2e/docx-track.spec.ts @@ -62,7 +62,7 @@ describe('docx tracked changes', () => { await v.page.waitForTimeout(250) let ps = await docxParas((await v.save()).bytes) expect(show(ps.find((p) => show(p).startsWith('Hire'))!)).toBe('Hire the platform tea[-m]') - // typing at the caret (Save took the focus: put it back after "tea") goes in as inserted text, before the deletion + // typing at the caret, after "tea", goes in as inserted text, before the deletion await v.selectText('platform tea', 'end') await v.page.keyboard.type('ms') await v.page.waitForTimeout(250) diff --git a/e2e/focus-qa3.spec.ts b/e2e/focus-qa3.spec.ts index 972f31b..b67c596 100644 --- a/e2e/focus-qa3.spec.ts +++ b/e2e/focus-qa3.spec.ts @@ -86,3 +86,68 @@ describe('QA 3: spreadsheets', () => { expect(v.errors).toEqual([]) }) }) + +describe('a click on Save leaves the keyboard in the document', () => { + test('a document: the caret stays, Ctrl/⌘+Z undoes the typing just saved', async () => { + const v = await viewer({ src: 'samples/sample.docx', editable: true, onSave: true }) + await v.page.locator('.de-ebar').waitFor() + await v.selectText('Quarterly Report', 'end') + await v.page.keyboard.type('XYZ') + await v.page.waitForTimeout(200) + await v.save() + expect((await active(v)).cls).toContain('de-pages') + await v.page.keyboard.press('ControlOrMeta+z') + await v.page.waitForTimeout(200) + expect(await v.pagesText()).not.toContain('Quarterly ReportXYZ') + expect(v.errors).toEqual([]) + }) + + test('a sheet: the grid keeps the focus, Ctrl/⌘+Z takes the cell back', async () => { + const v = await viewer({ src: 'samples/sample.xlsx', editable: true, onSave: true }) + await v.page.locator('.de-ebar').waitFor() + await v.typeCell('J10', 'saved') + await v.save() + expect((await active(v)).inViewer).toBe(true) + await v.page.keyboard.press('ControlOrMeta+z') + await v.page.waitForTimeout(300) + expect(await v.shown('J10')).toBe('') + expect(v.errors).toEqual([]) + }) + + test('slides: Ctrl/⌘+Z takes back the text typed in a shape', async () => { + const v = await viewer({ src: 'samples/sample.pptx', editable: true, onSave: true }) + await v.page.locator('.de-ebar').waitFor() + const slide = v.page.locator('.de-slide-frame').first() + await slide.getByText('office-engine').first().click() + await v.page.locator('.de-txt-edit').waitFor() + await v.page.keyboard.press('ControlOrMeta+a') + await v.page.keyboard.type('Saved title') + await v.page.keyboard.press('Escape') + await v.page.keyboard.press('Escape') + await v.page.waitForTimeout(300) + await v.save() + expect((await active(v)).cls).toContain('de-scroll') + await v.page.keyboard.press('ControlOrMeta+z') + await v.page.waitForFunction(() => !document.querySelector('.de-slide-frame')?.textContent?.includes('Saved title')) + expect(await slide.innerText()).toContain('office-engine') + expect(v.errors).toEqual([]) + }) + + test('saving: the button is shown as busy but keeps a keyboard focus it had', async () => { + const v = await viewer({ src: 'samples/sample.docx', editable: true, onSave: true }) + await v.page.locator('.de-ebar').waitFor() + await v.selectText('Quarterly Report', 'end') + await v.page.keyboard.type('!') + await v.page.waitForTimeout(200) + const button = v.barButton('Save') + await button.focus() + const n = await saves(v) + await v.page.keyboard.press('Enter') + await v.waitEvent('save', n + 1) + await v.page.waitForTimeout(100) + const a = await active(v) + expect(a.tag).toBe('BUTTON') + expect(a.inViewer).toBe(true) + expect(v.errors).toEqual([]) + }) +}) diff --git a/e2e/markdown-math.spec.ts b/e2e/markdown-math.spec.ts index a62afa2..46d567d 100644 --- a/e2e/markdown-math.spec.ts +++ b/e2e/markdown-math.spec.ts @@ -124,8 +124,7 @@ describe('Markdown math in the document', () => { // (the paragraph is written again: its dollar signs are escaped only where they would be read as math) expect(saved).toContain('Euler’s identity: $e^{i\\pi} + 1 = 0$It costs $5 and $10, see `$x$`.') expect(saved).toContain('Euler’s identity: $e^{i\\pi} + 1 = 0$ is famous.') - // (Save took the focus) - await v.selectText('It costs', 'start') + // (Save left the focus in the document) await page.keyboard.press('Control+z') await page.waitForTimeout(300) expect(await inline()).toBe(3) diff --git a/e2e/pptx.spec.ts b/e2e/pptx.spec.ts index 04b45c9..2aecd97 100644 --- a/e2e/pptx.spec.ts +++ b/e2e/pptx.spec.ts @@ -77,11 +77,7 @@ describe('pptx editing', () => { expect(s1.meta.count).toBe(5) expect((await s1.slide(0)).els.some((e: any) => e.geom === 'rect' && e.fill?.c === '#00ff00')).toBe(true) - // Save took the focus: select the shape again (it is the topmost at the slide center) - const f = (await slide1(v).boundingBox())! - await v.page.mouse.click(f.x + f.width / 2, f.y + f.height / 2) - // a click on a shape with a text body edits its text: Esc keeps the shape selected - if (await v.page.locator('.de-txt-edit').count()) await stopEditing(v) + // Save left the shape selected await v.btn('Delete').waitFor() await v.btn('Delete').click() await v.page.waitForTimeout(300) diff --git a/e2e/xlsx.spec.ts b/e2e/xlsx.spec.ts index 875eceb..3cf37aa 100644 --- a/e2e/xlsx.spec.ts +++ b/e2e/xlsx.spec.ts @@ -1087,8 +1087,7 @@ describe('xlsx whole columns and rows (QA 19/11/2026, P2-042)', () => { // the column holds what was typed and where the row crosses it, not a cell per row expect((xml.match(/ )} {client && canSave && ((editing && !readOnly) || dirty) && ( - diff --git a/src/react/styles.css b/src/react/styles.css index c774f62..997c28a 100644 --- a/src/react/styles.css +++ b/src/react/styles.css @@ -705,7 +705,7 @@ .de-mode-on { border-color: var(--de-accent); color: var(--de-accent); } .de-save-dirty { background: var(--de-accent); border-color: var(--de-accent); color: var(--de-accent-ink); } .de-save-dirty:hover { background: var(--de-accent-hover); } -.de-mode:disabled { opacity: 0.6; cursor: default; } +.de-mode:disabled, .de-mode[aria-disabled='true'] { opacity: 0.6; cursor: default; } .de-ebar-host { flex: none; padding: 6px 10px;