Skip to content

Use ErrorTag, AriaInvalid, AriaDisabled, FlashTag across examples#50

Merged
adnaan merged 2 commits intomainfrom
fix/issue-47-error-flash-helpers
Apr 3, 2026
Merged

Use ErrorTag, AriaInvalid, AriaDisabled, FlashTag across examples#50
adnaan merged 2 commits intomainfrom
fix/issue-47-error-flash-helpers

Conversation

@adnaan
Copy link
Copy Markdown
Contributor

@adnaan adnaan commented Apr 3, 2026

Closes #47

Changes

Replace verbose {{if .lvt.HasError}} / {{if .lvt.HasFlash}} conditional blocks with concise framework helpers across all affected examples.

Template helpers used

  • ErrorTag — renders <small>error message</small> or nothing
  • AriaInvalid — renders aria-invalid="true" when field has error, or nothing
  • AriaDisabled — renders aria-disabled="true" on submit buttons when any specified field has an error
  • FlashTag — renders <output role="status|alert"> or nothing

Files changed

File Changes
todos/todos.tmpl AriaInvalid/ErrorTag for "text" field; AriaDisabled on Add button
login/main.go Removed state.Error field; empty fields → NewFieldError; wrong password → ctx.SetFlash("error", ...)
login/templates/auth.html FlashTag "error" replaces {{.Error}}; AriaInvalid/ErrorTag on fields; AriaDisabled on Login button
progressive-enhancement/progressive-enhancement.tmpl FlashTag replaces if-blocks; AriaInvalid/ErrorTag/AriaDisabled on add form
ws-disabled/ws-disabled.tmpl Same pattern for label and url fields
flash-messages/flash.tmpl FlashTag ×4 replaces HasAnyFlash/HasFlash block; AriaInvalid/ErrorTag/AriaDisabled on item form

Not changed

  • avatar-upload.Error is on upload progress entries, not framework field errors
  • chat, counter, live-preview, shared-notepad — no form validation errors

All 8 example tests pass.

Replace verbose {{if .lvt.HasError}} / {{if .lvt.HasFlash}} conditional
blocks with concise framework helpers in all affected examples.

- todos: AriaInvalid/ErrorTag for 'text' field, AriaDisabled on Add button
- login: remove state.Error field; use NewFieldError for empty fields,
  ctx.SetFlash for wrong password; update template with FlashTag/AriaInvalid
- progressive-enhancement: FlashTag replaces if-blocks, AriaInvalid/ErrorTag/
  AriaDisabled on add form
- ws-disabled: same pattern for label and url fields
- flash-messages: replace HasAnyFlash/HasFlash block with four FlashTag calls,
  AriaInvalid/ErrorTag/AriaDisabled on item form

Closes #47

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 3, 2026 03:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates multiple LiveTemplate examples to use the newer template helper functions for rendering flash messages and field validation state, replacing repetitive conditional blocks with concise helper calls.

Changes:

  • Replaced HasFlash/Flash and HasError/Error conditional blocks with FlashTag, AriaInvalid, and ErrorTag in templates.
  • Added AriaDisabled usage on submit buttons to reflect invalid form state.
  • Refactored login example to use field-level errors (NewFieldError) and flash for invalid credentials, removing the state.Error field.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ws-disabled/ws-disabled.tmpl Uses FlashTag, AriaInvalid, ErrorTag, and AriaDisabled to simplify flash + form error rendering.
todos/todos.tmpl Uses AriaInvalid/ErrorTag for the add form and AriaDisabled on the submit button.
progressive-enhancement/progressive-enhancement.tmpl Replaces flash/error conditional blocks with helper tags and adds AriaDisabled to submit.
login/templates/auth.html Displays login errors via FlashTag and field errors via AriaInvalid/ErrorTag; disables submit via AriaDisabled.
login/main.go Removes AuthState.Error; uses NewFieldError for required fields; uses SetFlash("error", ...) for invalid credentials.
flash-messages/flash.tmpl Replaces verbose flash rendering with multiple FlashTag calls; uses AriaInvalid/ErrorTag/AriaDisabled for the input form.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +14 to +17
{{.lvt.FlashTag "success"}}
{{.lvt.FlashTag "error"}}
{{.lvt.FlashTag "warning"}}
{{.lvt.FlashTag "info"}}
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flash-messages example documentation is now out of sync with this template change: flash-messages/README.md (and the “About Flash Messages” blockquote in this template) still instructs using .lvt.HasAnyFlash/.lvt.HasFlash/.lvt.Flash, but the template now demonstrates .lvt.FlashTag. Please update the example docs/text to match the new recommended helper (or mention both patterns explicitly).

Copilot uses AI. Check for mistakes.
Update the 'About Flash Messages' info box to mention FlashTag as the
recommended rendering helper, while noting the manual HasFlash/Flash
pattern for custom use cases.

Addresses Copilot review comment.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@adnaan adnaan merged commit a34f733 into main Apr 3, 2026
9 checks passed
@adnaan adnaan deleted the fix/issue-47-error-flash-helpers branch April 3, 2026 07:09
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.

Update all examples to use ErrorTag, AriaInvalid, AriaDisabled, FlashTag

2 participants