Skip to content

docs: nest guide 06 modals inside the root element - #170

Merged
grindlemire merged 2 commits into
mainfrom
docs/nest-guide-06-modals
Sep 20, 2026
Merged

grindlemire merged 2 commits into
mainfrom
docs/nest-guide-06-modals

Conversation

@grindlemire

@grindlemire grindlemire commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

Two snippets in the state guide, the one under "Driving a Modal with State" and the complete example, put the <modal> after the closing tag of the templ's root <div>. A templ only returns its first top-level element, but the generator still emits the rest, so the modal mounted, registered as an overlay and drew on screen while never joining the element tree. Its buttons were never registered as focusable, and Enter, Escape, Tab and clicks all went nowhere. In the first snippet that leaves the dialog stuck open, since Escape is bound to quit.

Both snippets now nest the modal inside the root div, the same shape as examples/06-state, and a short note after the first one calls out the pitfall. Guide 09 had the same problem and #168 fixes it. I swept the remaining guides for the pattern and for anything that fails to generate or vet, and these were the only two. #169 tracks an analyzer error for templ bodies with more than one top-level element so this cannot pass tui check again.

The complete example also claimed its reset handler batched the two state writes, in the intro sentence and in a comment, while the code makes plain Set() calls like examples/06-state does. The claim is gone; the batching section above it still shows the real app.Batch() form.

@codecov

codecov Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.74%. Comparing base (4c7b128) to head (d3016a6).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #170   +/-   ##
=======================================
  Coverage   84.74%   84.74%           
=======================================
  Files         169      169           
  Lines       21588    21588           
=======================================
  Hits        18295    18295           
  Misses       2633     2633           
  Partials      660      660           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@greptile-apps

greptile-apps Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The documentation-only change appears safe to merge and corrects previously non-interactive modal examples.

Summary

This documentation change corrects both state-guide modal examples by nesting each modal within the template’s root element.

  • Ensures modal controls participate in element-tree focus and input discovery.
  • Adds an accurate warning about placing overlays after a template’s returned root.
  • Preserves valid, balanced template structure in both snippets.

Reviews (1) · Last reviewed commit: "docs: nest guide 06 modals inside the ro..."

@grindlemire
grindlemire merged commit d49778e into main Sep 20, 2026
10 checks passed
@grindlemire
grindlemire deleted the docs/nest-guide-06-modals branch September 20, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant