Editor: strings and dead selectors pinned; three review leftovers
TestQuieterStrings holds the approved strings table (25 keys, all read) to en.toml and editorStrings, every listed key read, and the retired keys gone, block.level and block.box kept because the markup still reads them. TestQuieterNoDeadSelectors keeps the old card's, strip foot's and notes icon's selectors out of editor.css and the fixtures; the notes tab's JS test now checks the tab's whole attribute set instead of naming the old dot. The leftovers from review: - The Background and Transition popovers are centred under their row (anchor-center), so on a desktop they hang inside the card's side edges; they still stay inside a narrow window. - The layout pictures' radio group is named by the group's label, and the slide's group is no longer a second group named This slide, nor has a legend saying it again: a screen reader hears it once. - TestQuieterPhoneOnly checks the "Editing the phone layout" line at 1000x800 and 320x700 in Phone and Both: inside the bar and window, its words whole, clear of the view switch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 files changed,
+293
−27
fixtures/notes-card.test.mjs+4 −3internal/slides/static/editor.css+7 −2internal/slides/templates/editor.html+5 −3internal/slidestest/browser_quieter_test.go+92 −0internal/slidestest/editor_tidy_test.go+43 −14internal/slidestest/quieter_test.go+142 −5
diff --git a/fixtures/notes-card.test.mjs b/fixtures/notes-card.test.mjs| index 0dd777d..cd67eed 100644 |
| --- a/fixtures/notes-card.test.mjs |
| +++ b/fixtures/notes-card.test.mjs |
| @@ -364,9 +364,10 @@ test('refresh() writes the tab\'s text: the word for notes, and the count of wor |
| n = 0 |
| card.refresh() |
| assert.equal(p.open.textContent, 'Notes') |
| - // No dot, no name of its own: the text is the name. |
| - assert.equal(p.open.hasAttribute('data-has-notes'), false) |
| - assert.equal(p.open.hasAttribute('aria-label'), false) |
| + // No dot, no name of its own: the text is the name. The tab keeps |
| + // the server's two strings and is given no attribute of its own. |
| + assert.deepEqual([...p.open.attrs.keys()].sort(), ['data-label', 'data-label-words']) |
| + assert.deepEqual(p.open.dataset, {}) |
| }) |
| test('refresh() writes nothing when the tab already says it (the server\'s first paint)', () => { |
diff --git a/internal/slides/static/editor.css b/internal/slides/static/editor.css| index 4fb6f2b..a08549b 100644 |
| --- a/internal/slides/static/editor.css |
| +++ b/internal/slides/static/editor.css |
| @@ -1297,9 +1297,14 @@ |
| @supports (position-area: bottom) { |
| [slides-slide-pop] { |
| inset: auto; |
| + /* Centred under its row, so on a desktop it hangs inside the |
| + card's side edges (it is a little wider than the row, less |
| + than the row and the card's padding); in a narrow window it is |
| + shifted to stay inside it. */ |
| + justify-self: anchor-center; |
| margin: 4px 0; |
| - position-area: bottom span-left; |
| - position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline; |
| + position-area: bottom; |
| + position-try-fallbacks: flip-block; |
| } |
| #slides-pop-background { |
| position-anchor: --slides-row-background; |
diff --git a/internal/slides/templates/editor.html b/internal/slides/templates/editor.html| index 3068ee5..76a00ff 100644 |
| --- a/internal/slides/templates/editor.html |
| +++ b/internal/slides/templates/editor.html |
| @@ -552,13 +552,15 @@ |
| </p> |
| </div> |
| </div> |
| - <div estilo-inspector-group role="group" aria-labelledby="slides-g-slide" data-group="slide"> |
| + {{/* Not a named group, unlike the box's: the label names the |
| + pictures' radio group, and a group around it named the same |
| + would have a screen reader say This slide twice. */}} |
| + <div estilo-inspector-group data-group="slide"> |
| <span estilo-inspector-label id="slides-g-slide">{{.L "group.slide"}}</span> |
| {{/* The layout: one radio group of pictures, four across, each |
| named by its tooltip and its accessible name. The painted |
| slide's is lit by the server, so the first paint is final. */}} |
| - <fieldset slides-layout-pick> |
| - <legend class="rst-sr-only">{{.L "group.slide"}}</legend> |
| + <fieldset slides-layout-pick aria-labelledby="slides-g-slide"> |
| {{template "slides-layout-pick-item" dict "Value" "title" "Label" (.L "template.title") "Lit" .SlideLit}} |
| {{template "slides-layout-pick-item" dict "Value" "title-body" "Label" (.L "template.title-body") "Lit" .SlideLit}} |
| {{template "slides-layout-pick-item" dict "Value" "two-column" "Label" (.L "template.two-column") "Lit" .SlideLit}} |
diff --git a/internal/slidestest/browser_quieter_test.go b/internal/slidestest/browser_quieter_test.go| index 4346fbc..7efe256 100644 |
| --- a/internal/slidestest/browser_quieter_test.go |
| +++ b/internal/slidestest/browser_quieter_test.go |
| @@ -43,6 +43,37 @@ func axName(t *testing.T, rig *harness.Rig, sel string) string { |
| return name |
| } |
| +// axNamed is the role of every node in the accessibility tree under the |
| +// first element sel matches (it included) that Chromium names name, in |
| +// tree order: what a screen reader announces with that name as it moves |
| +// into or through it. Text itself (StaticText, InlineTextBox) is left |
| +// out: a label's own drawn words are what a name is made from, not a |
| +// second announcement of it. |
| +func axNamed(t *testing.T, rig *harness.Rig, sel, name string) []string { |
| + t.Helper() |
| + var nodes []*cdp.Node |
| + rig.Run(chromedp.Nodes(sel, &nodes, chromedp.ByQuery)) |
| + var roles []string |
| + rig.Run(chromedp.ActionFunc(func(ctx context.Context) error { |
| + found, err := accessibility.QueryAXTree().WithBackendNodeID(nodes[0].BackendNodeID).WithAccessibleName(name).Do(ctx) |
| + if err != nil { |
| + return err |
| + } |
| + for _, n := range found { |
| + var role string |
| + if n.Role != nil { |
| + _ = json.Unmarshal(n.Role.Value, &role) |
| + } |
| + if n.Ignored || role == "StaticText" || role == "InlineTextBox" { |
| + continue |
| + } |
| + roles = append(roles, role) |
| + } |
| + return nil |
| + })) |
| + return roles |
| +} |
| + |
| // parkPointer moves the pointer to the window's bottom end corner, off |
| // the strip: hover lifts a thumbnail and shows its menu, and the strip |
| // at rest is what is measured. |
| @@ -1230,6 +1261,16 @@ func TestQuieterLayoutPictures(t *testing.T) { |
| } |
| te.rig.Screen(`[slides-inspector]`, "the card at rest on a canvas slide") |
| + // The pictures are one radio group, named This slide by the group's |
| + // label, and a screen reader is told This slide once: no second |
| + // group around it, no legend inside it, says it again. |
| + if name := axName(t, te.rig, `[slides-layout-pick]`); name != "This slide" { |
| + t.Errorf("the pictures' radio group is named %q, want This slide", name) |
| + } |
| + if said := axNamed(t, te.rig, `[data-group="slide"]`, "This slide"); len(said) != 1 || said[0] != "group" { |
| + t.Errorf("the slide's group says This slide as %v; want once, as the pictures' group", said) |
| + } |
| + |
| // Every template from a flow slide, then Free placement. |
| flow := ids["title"] |
| te.goToSlide(flow) |
| @@ -1357,6 +1398,16 @@ func TestQuieterSlideRows(t *testing.T) { |
| waitFor(`document.querySelector('`+pop+` [name="rst-slide-`+row+`"]').checkVisibility()`), |
| ) |
| te.rig.Screen(pop, "the "+row+" popover") |
| + // On a desktop the popover hangs inside the card's two side edges. |
| + var within string |
| + te.rig.Run(chromedp.Evaluate(`(() => { |
| + const p = document.querySelector('`+pop+`').getBoundingClientRect(), c = document.querySelector('[slides-inspector]').getBoundingClientRect() |
| + if (p.left < c.left - 0.5 || p.right > c.right + 0.5) return 'the popover runs ' + p.left + '..' + p.right + ', the card ' + c.left + '..' + c.right |
| + return '' |
| + })()`, &within)) |
| + if within != "" { |
| + t.Errorf("at 1280x720 the %s popover is not within the card's side edges: %s", row, within) |
| + } |
| te.rig.Run( |
| chromedp.Focus(pop+` [name="rst-slide-`+row+`"]`, chromedp.ByQuery), |
| chromedp.KeyEvent(kb.Escape), |
| @@ -1504,4 +1555,45 @@ func TestQuieterPhoneOnly(t *testing.T) { |
| t.Errorf("switching to %s view dropped the box's selection", v) |
| } |
| } |
| + |
| + // Narrow windows (the stage bar is a three-column grid): the line |
| + // stays inside the bar and the window, all its words shown, and |
| + // clear of the view switch, with the box still selected. |
| + for _, size := range [][2]int64{{1000, 800}, {320, 700}} { |
| + te.size(size[0], size[1]) |
| + for _, v := range []string{"phone", "both"} { |
| + te.view(v) |
| + drawn("false,true,true", fmt.Sprintf("a selected box in %s view at %dx%d", v, size[0], size[1])) |
| + var got string |
| + te.rig.Run( |
| + chromedp.Evaluate(`document.querySelector('[slides-stage-bar]').scrollIntoView({ block: 'center', inline: 'nearest' })`, nil), |
| + chromedp.Evaluate(phoneLineJS, &got), |
| + ) |
| + if got != "" { |
| + t.Errorf("in %s view at %dx%d: %s", v, size[0], size[1], got) |
| + } |
| + } |
| + } |
| } |
| + |
| +// phoneLineJS reports what is wrong with where the "Editing the phone |
| +// layout" line is drawn: outside the stage bar or the window, its words |
| +// cut off, or over the view switch. "" is the pass. |
| +const phoneLineJS = `(() => { |
| + const line = document.querySelector('[slides-phone-editing]') |
| + const l = line.getBoundingClientRect(), b = document.querySelector('[slides-stage-bar]').getBoundingClientRect() |
| + const s = document.querySelector('[slides-switcher]').getBoundingClientRect() |
| + const out = [], at = r => JSON.stringify([r.left, r.top, r.right, r.bottom].map(Math.round)) |
| + if (l.width === 0 || l.height === 0) return 'the line has no box' |
| + if (l.left < b.left - 0.5 || l.top < b.top - 0.5 || l.right > b.right + 0.5 || l.bottom > b.bottom + 0.5) |
| + out.push('the line ' + at(l) + ' is outside the stage bar ' + at(b)) |
| + if (l.left < -0.5 || l.top < -0.5 || l.right > innerWidth + 0.5 || l.bottom > innerHeight + 0.5) |
| + out.push('the line ' + at(l) + ' is outside the window ' + innerWidth + 'x' + innerHeight) |
| + // The line is inline: its words overflow the live region that holds it. |
| + const box = line.closest('[slides-phone-status]') |
| + if (box.scrollWidth > box.clientWidth + 0.5 || box.scrollHeight > box.clientHeight + 0.5) |
| + out.push('the line\'s words are cut off (' + box.scrollWidth + 'x' + box.scrollHeight + ' in ' + box.clientWidth + 'x' + box.clientHeight + ')') |
| + if (l.left < s.right && s.left < l.right && l.top < s.bottom && s.top < l.bottom) |
| + out.push('the line ' + at(l) + ' overlaps the view switch ' + at(s)) |
| + return out.join('; ') |
| +})()` |
diff --git a/internal/slidestest/editor_tidy_test.go b/internal/slidestest/editor_tidy_test.go| index c24ef1a..fd30d14 100644 |
| --- a/internal/slidestest/editor_tidy_test.go |
| +++ b/internal/slidestest/editor_tidy_test.go |
| @@ -535,7 +535,8 @@ func TestEditorTidyCardShape(t *testing.T) { |
| } |
| // The groups themselves: estilo's labelled group, its label's id the |
| - // group's name, in the spec's order. |
| + // group's name (the slide's names its pictures instead), in the |
| + // spec's order. |
| for _, w := range []struct { |
| section string |
| names []string |
| @@ -548,7 +549,13 @@ func TestEditorTidyCardShape(t *testing.T) { |
| for _, g := range tidyGroups(form) { |
| got = append(got, g.name) |
| open := form[g.start : g.start+strings.Index(form[g.start:], ">")+1] |
| - if want := `<div estilo-inspector-group role="group" aria-labelledby="slides-g-` + g.name + `" data-group="` + g.name + `">`; open != want { |
| + want := `<div estilo-inspector-group role="group" aria-labelledby="slides-g-` + g.name + `" data-group="` + g.name + `">` |
| + if g.name == "slide" { |
| + // Its label names the pictures' radio group instead (Q10): |
| + // a group around them named the same said it twice. |
| + want = `<div estilo-inspector-group data-group="slide">` |
| + } |
| + if open != want { |
| t.Errorf("the %s group opens %s, want %s", g.name, open, want) |
| } |
| label := `^<div[^>]*>\s*<span estilo-inspector-label id="slides-g-` + regexp.QuoteMeta(g.name) + `">[^<]+</span>` |
| @@ -719,6 +726,39 @@ func goStrings(t *testing.T, src, name string) []string { |
| return out |
| } |
| +// editorKeysRead is every slides.editor key the editor reads, without |
| +// its prefix: by editor.html through L (the strings a module needs |
| +// included: the template renders them into the data-* attributes it |
| +// reads), by its add-block menus as type.<block type>, or by editor.go |
| +// itself through page.S. |
| +func editorKeysRead(t *testing.T, tmpl, src string) map[string]bool { |
| + t.Helper() |
| + read := map[string]bool{} |
| + for _, m := range regexp.MustCompile(`\.L "([^"]+)"`).FindAllStringSubmatch(tmpl, -1) { |
| + read[m[1]] = true |
| + } |
| + for _, m := range regexp.MustCompile(`\.L \(printf "([^"%]*)%s" \.\)`).FindAllStringSubmatch(tmpl, -1) { |
| + for _, b := range goStrings(t, src, "blockTypes") { |
| + read[m[1]+b] = true |
| + } |
| + } |
| + for _, m := range regexp.MustCompile(`page\.S\["([^"]+)"\]`).FindAllStringSubmatch(src, -1) { |
| + read[m[1]] = true |
| + } |
| + return read |
| +} |
| + |
| +// editorCatalog is en.toml's slides.editor strings, by key without the |
| +// prefix. |
| +func editorCatalog(t *testing.T) map[string]string { |
| + t.Helper() |
| + catalog := map[string]string{} |
| + for _, m := range regexp.MustCompile(`(?m)^slides\.editor\.(\S+) = "(.*)"$`).FindAllStringSubmatch(readSource(t, "locales/en.toml"), -1) { |
| + catalog[m[1]] = m[2] |
| + } |
| + return catalog |
| +} |
| + |
| // TestEditorTidyStrings: the strings of the tidied editor are catalog |
| // keys, each in en.toml with the strings table's English and in |
| // editorStrings; every key in editorStrings is read (by editor.html |
| @@ -815,18 +855,7 @@ func TestEditorTidyStrings(t *testing.T) { |
| } |
| // Every listed key is read, and every key read is listed. |
| - read := map[string]bool{} |
| - for _, m := range regexp.MustCompile(`\.L "([^"]+)"`).FindAllStringSubmatch(tmpl, -1) { |
| - read[m[1]] = true |
| - } |
| - for _, m := range regexp.MustCompile(`\.L \(printf "([^"%]*)%s" \.\)`).FindAllStringSubmatch(tmpl, -1) { |
| - for _, b := range goStrings(t, src, "blockTypes") { |
| - read[m[1]+b] = true |
| - } |
| - } |
| - for _, m := range regexp.MustCompile(`page\.S\["([^"]+)"\]`).FindAllStringSubmatch(src, -1) { |
| - read[m[1]] = true |
| - } |
| + read := editorKeysRead(t, tmpl, src) |
| for _, k := range keys { |
| if !read[k] { |
| t.Errorf("editorStrings lists %s, which nothing reads", k) |
diff --git a/internal/slidestest/quieter_test.go b/internal/slidestest/quieter_test.go| index 4566230..7a4f302 100644 |
| --- a/internal/slidestest/quieter_test.go |
| +++ b/internal/slidestest/quieter_test.go |
| @@ -405,7 +405,7 @@ func TestQuieterCardAtRest(t *testing.T) { |
| } |
| want := []string{ |
| `<span estilo-inspector-label id="slides-g-slide">`, |
| - `<fieldset slides-layout-pick>`, |
| + `<fieldset slides-layout-pick aria-labelledby="slides-g-slide">`, |
| `<div slides-slide-rows>`, |
| } |
| // The phone field is in the markup on every slide, marked as the |
| @@ -423,12 +423,13 @@ func TestQuieterCardAtRest(t *testing.T) { |
| t.Errorf("%s: the slide form still has a standing hint", where) |
| } |
| - // The pictures: a hidden legend, then eight labels, each its |
| - // name as tooltip and accessible name, wrapping its radio and its |
| + // The pictures: named This slide by the group's label alone (no |
| + // legend saying it again), then eight labels, each its name as |
| + // tooltip and accessible name, wrapping its radio and its |
| // drawing; the painted slide's lit. |
| pick := parts[1] |
| - if !strings.Contains(pick, `<legend class="rst-sr-only">This slide</legend>`) { |
| - t.Errorf("%s: the pictures have no visually hidden legend saying This slide:\n%s", where, pick) |
| + if strings.Contains(pick, "<legend") { |
| + t.Errorf("%s: the pictures still have a legend; the group's label names them:\n%s", where, pick) |
| } |
| labels := regexp.MustCompile(`(?s)<label .*?</label>`).FindAllString(pick, -1) |
| if len(labels) != len(layoutPictures) { |
| @@ -767,3 +768,139 @@ func TestQuieterNotesMarkup(t *testing.T) { |
| t.Errorf("with no slides the tab is %s%s; want it disabled, saying Notes", tab, text) |
| } |
| } |
| + |
| +// quieterStrings is the quieter editor's strings table as Paul approved |
| +// it (rules.md, the copy review before Q2): every key under |
| +// slides.editor., with its English. |
| +var quieterStrings = []struct{ key, english string }{ |
| + {"file.deck", "Deck settings…"}, |
| + {"deck.settings", "Deck settings"}, |
| + {"layout.free", "Free placement"}, |
| + {"layout.leave.confirm", "Put the boxes back into this layout's regions? Their positions are dropped. Undo brings them back."}, |
| + {"layout.leave", "Use the layout"}, |
| + {"layout.leave.cancel", "Keep free placement"}, |
| + {"level.1", "Title"}, {"level.2", "Heading"}, {"level.3", "Subheading"}, |
| + {"box.more", "More for this box"}, |
| + {"box.place", "Position and size…"}, |
| + {"place.title", "Position and size"}, |
| + {"box.region", "Move to region"}, |
| + {"box.delete", "Delete"}, |
| + {"view.outline", "Outline"}, |
| + {"outline.none", "This slide has no boxes yet."}, |
| + {"phone.editing", "Editing the phone layout"}, |
| + {"notes.tab", "Notes"}, |
| + {"notes.tab.words", "Notes · {n} words"}, |
| + {"keys.box.forward", "Bring the box forward"}, |
| + {"keys.box.back", "Send the box back"}, |
| + {"keys.box.up", "Move the box up"}, |
| + {"keys.box.down", "Move the box down"}, |
| + {"keys.box.delete", "Delete the selected box"}, |
| + {"keys.box.menu", "Open the box's menu"}, |
| +} |
| + |
| +// TestQuieterStrings (Q10): every key of the approved strings table is |
| +// read by the editor (none went unused), is in en.toml with exactly the |
| +// table's English, and is listed in editorStrings; the keys the table |
| +// reuses are still there; every key in editorStrings is read (as |
| +// TestEditorTidyStrings counts reading) and defined; and the keys the |
| +// quieter editor retired are gone from both, except block.level (the |
| +// heading level's legend) and block.box (the position fields' hidden |
| +// legend), which the finished markup still reads. |
| +func TestQuieterStrings(t *testing.T) { |
| + catalog := editorCatalog(t) |
| + src := readSource(t, "editor.go") |
| + tmpl := readSource(t, "templates/editor.html") |
| + read := editorKeysRead(t, tmpl, src) |
| + listed := map[string]bool{} |
| + keys := goStrings(t, src, "editorStrings") |
| + for _, k := range keys { |
| + listed[k] = true |
| + } |
| + |
| + if len(quieterStrings) != 25 { |
| + t.Fatalf("the strings table has %d keys, want the 25 Paul approved", len(quieterStrings)) |
| + } |
| + for _, c := range quieterStrings { |
| + if !read[c.key] { |
| + t.Errorf("nothing in the editor reads %s", c.key) |
| + } |
| + if got, ok := catalog[c.key]; !ok { |
| + t.Errorf("en.toml has no slides.editor.%s", c.key) |
| + } else if got != c.english { |
| + t.Errorf("slides.editor.%s is %q, want Paul's %q", c.key, got, c.english) |
| + } |
| + if !listed[c.key] { |
| + t.Errorf("editorStrings does not list %s", c.key) |
| + } |
| + } |
| + |
| + reused := []string{"slide.background", "slide.transition", "block.forward", "block.back", "block.move.up", "block.move.down", "keys.close"} |
| + for _, tpl := range []string{"title", "title-body", "two-column", "section", "image-full", "quote", "blank"} { |
| + reused = append(reused, "template."+tpl) |
| + } |
| + for _, r := range []string{"heading", "body", "aside", "media"} { |
| + reused = append(reused, "region."+r) |
| + } |
| + for _, k := range reused { |
| + if _, ok := catalog[k]; !ok || !listed[k] || !read[k] { |
| + t.Errorf("the reused key %s is not defined, listed and read (%v, %v, %v)", k, ok, listed[k], read[k]) |
| + } |
| + } |
| + |
| + for _, k := range keys { |
| + if !read[k] { |
| + t.Errorf("editorStrings lists %s, which nothing reads", k) |
| + } |
| + if _, ok := catalog[k]; !ok { |
| + t.Errorf("editorStrings lists %s, which en.toml does not define", k) |
| + } |
| + } |
| + |
| + for _, k := range []string{"slide.layout", "layout.flow", "layout.canvas", "layout.flow.desc", "layout.canvas.desc", |
| + "slide.template", "group.boxes", "inspector.blocks.none", "block.add", "block.delete", |
| + "notes.title", "notes.open", "notes.open.has", "inspector.deck", "deck.title", |
| + "block.region", "group.place"} { |
| + if _, ok := catalog[k]; ok { |
| + t.Errorf("en.toml still defines slides.editor.%s", k) |
| + } |
| + if listed[k] { |
| + t.Errorf("editorStrings still lists %s", k) |
| + } |
| + if read[k] { |
| + t.Errorf("the editor still reads %s", k) |
| + } |
| + } |
| + // Kept: the plan listed them as removed, but the finished markup |
| + // reads them. |
| + for _, k := range []string{"block.level", "block.box"} { |
| + if _, ok := catalog[k]; !ok || !listed[k] || !read[k] { |
| + t.Errorf("%s is still read by the markup, so it stays defined and listed (%v, %v, %v)", k, ok, listed[k], read[k]) |
| + } |
| + } |
| +} |
| + |
| +// TestQuieterNoDeadSelectors (Q10): what the strip's foot, the card's |
| +// Boxes list and its buttons, Add block, the notes' heading, the card's |
| +// Delete block, the layout's standing descriptions and the notes icon's |
| +// dot were drawn and wired by is gone from the stylesheet and the |
| +// bundle's sources (their tests included). |
| +func TestQuieterNoDeadSelectors(t *testing.T) { |
| + files := []string{filepath.Join("..", "slides", "static", "editor.css"), filepath.Join("..", "..", "fixtures", "editor-entry.js")} |
| + mjs, err := filepath.Glob(filepath.Join("..", "..", "fixtures", "*.mjs")) |
| + if err != nil || len(mjs) == 0 { |
| + t.Fatalf("no fixtures/*.mjs (%v)", err) |
| + } |
| + files = append(files, mjs...) |
| + for _, f := range files { |
| + b, err := os.ReadFile(f) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, dead := range []string{"slides-strip-foot", "slides-blocks-list", "slides-blocks-buttons", "slides-add-block", |
| + "slides-notes-heading", "slides-block-delete", "slides-seg-desc", "data-has-notes"} { |
| + if strings.Contains(string(b), dead) { |
| + t.Errorf("%s still mentions %s", filepath.Base(f), dead) |
| + } |
| + } |
| + } |
| +} |