Hide Edit's separators until the script that fills its groups runs
With scripting off Edit held Undo above two empty rules. Found by the scripts-off browser check; TestUnbuiltMenuItemsAreHidden now asserts it (red with one rule left visible).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+11
−2
internal/sheets/chrome_menu_test.go+7 −0internal/sheets/templates/sheet.html+4 −2
CI passed — run details
CI log
amadan: .amadan/timeout: this job's budget is 15m0s (this runner allows up to 30m0s) === vet === CGO_ENABLED=0 go vet ./... === fmt === === build === CGO_ENABLED=0 go build ./... === migrations === rastrillo migration check rastrillo migration check: models and migrations agree === go-test === CGO_ENABLED=0 go test -count=1 ./... ? amadan.net/oficina/sheets/cmd/sheets [no test files] ok amadan.net/oficina/sheets/internal/guardstest 0.082s ok amadan.net/oficina/sheets/internal/sheets 14.806s ok amadan.net/oficina/sheets/internal/sheets/calc 0.011s ok amadan.net/oficina/sheets/internal/sheets/format 0.005s ok amadan.net/oficina/sheets/internal/sheets/live 0.054s ok amadan.net/oficina/sheets/internal/sheets/seal 0.002s ok amadan.net/oficina/sheets/internal/sheets/sealtest 0.003s ok amadan.net/oficina/sheets/internal/sheets/store 3.230s ok amadan.net/oficina/sheets/internal/sheets/xlsx 0.318s ? amadan.net/oficina/sheets/tools/gencorpus [no test files] === race === go test -race -count=1 ./internal/sheets/store/... ./internal/sheets/live/... ok amadan.net/oficina/sheets/internal/sheets/store 69.127s ok amadan.net/oficina/sheets/internal/sheets/live 1.098s
diff --git a/internal/sheets/chrome_menu_test.go b/internal/sheets/chrome_menu_test.go| index 1574919..c3e1b2c 100644 |
| --- a/internal/sheets/chrome_menu_test.go |
| +++ b/internal/sheets/chrome_menu_test.go |
| @@ -156,6 +156,13 @@ func TestUnbuiltMenuItemsAreHidden(t *testing.T) { |
| t.Errorf("%s is shown before the script that runs it", cmd) |
| } |
| } |
| + // With scripting off Edit holds Undo alone, so its separators are |
| + // script-only too: no rule above an empty group. |
| + edit := menubar[strings.Index(menubar, "<summary estilo-menubar-title>Edit</summary>"):] |
| + edit = edit[:strings.Index(edit, "</details>")] |
| + if n, hidden := strings.Count(edit, "<hr"), strings.Count(edit, "<hr data-needs-js hidden>"); n == 0 || n != hidden { |
| + t.Errorf("Edit has %d separators, %d of them hidden until script: with scripting off they rule off empty groups", n, hidden) |
| + } |
| // The shortcuts moved to the account menu, as a dialog that exists. |
| if !strings.Contains(body, `<button estilo-menu-item type="button" commandfor="sheets-shortcuts" command="show-modal"><span estilo-menu-label>Keyboard shortcuts…</span></button>`) { |
| t.Error("the account menu's Help does not open the shortcuts") |
diff --git a/internal/sheets/templates/sheet.html b/internal/sheets/templates/sheet.html| index e8f5398..e164468 100644 |
| --- a/internal/sheets/templates/sheet.html |
| +++ b/internal/sheets/templates/sheet.html |
| @@ -132,7 +132,9 @@ |
| it posts to the same route the keyboard shortcut fetches, so |
| there is one undo and not two that can disagree. */}} |
| <form method="post" action="/sheets/{{.Data.Sheet.ID}}/undo"><button estilo-menu-item type="submit"><span estilo-menu-label>Undo</span><kbd estilo-menu-key>{{.Frame.Keys.undo}}</kbd></button></form> |
| -<hr> |
| +{{/* The separators around the script-only groups are script-only too: |
| + with scripting off Undo stands alone, not above two empty rules. */}} |
| +<hr data-needs-js hidden> |
| <button estilo-menu-item type="button" data-cmd="cut" hidden><span estilo-menu-label>Cut</span><kbd estilo-menu-key>{{.Frame.Keys.cut}}</kbd></button> |
| <button estilo-menu-item type="button" data-cmd="copy" hidden><span estilo-menu-label>Copy</span><kbd estilo-menu-key>{{.Frame.Keys.copy}}</kbd></button> |
| {{/* Paste is here despite the browser being allowed to refuse a menu |
| @@ -143,7 +145,7 @@ |
| permission at all, because a paste EVENT carries its own data. */}} |
| <button estilo-menu-item type="button" data-cmd="paste" hidden><span estilo-menu-label>Paste</span><kbd estilo-menu-key>{{.Frame.Keys.paste}}</kbd></button> |
| <button estilo-menu-item type="button" data-cmd="clear" hidden><span estilo-menu-label>Clear contents</span><kbd estilo-menu-key>{{.Frame.Keys.delete}}</kbd></button> |
| -<hr> |
| +<hr data-needs-js hidden> |
| {{/* Fill down and fill right are the menu equivalents of the grid's |
| drag handle — AGENTS.md requires one for every drag-only |
| affordance. Ctrl+R is reload in every browser, so fill right is |