Skip to content

FOLLOW-UP: Couple spaNavMaxStep with template (from PR #74) #75

@adnaan

Description

@adnaan

Context

This follow-up task was identified during the review of PR #74.

Source PR: #74
PR Title: feat: patterns example Session 4 (patterns #17-21) — dialogs, tabs & navigation
Suggested by: @claude[bot] (PR comment, recurring across rounds 5, 7, 9, 10, 11)

Task Description

patterns/handlers_navigation.go defines spaNavMaxStep = 3, but templates/navigation/spa-navigation.tmpl hardcodes Step {{.Step}} of 3 with the 3 as a literal.

If spaNavMaxStep is ever changed (e.g., to demonstrate a 5-step flow), the template silently shows the wrong total.

Suggested Fix

Add a MaxStep int field to SPANavState and populate it in Mount (or in the handler factory's initial state), then render Step {{.Step}} of {{.MaxStep}} in the template.

type SPANavState struct {
    Title    string
    Category string
    Step     int
    MaxStep  int
}

func (c *SPANavController) Mount(state SPANavState, ctx *livetemplate.Context) (SPANavState, error) {
    state.MaxStep = spaNavMaxStep
    // ... existing logic
}

Original Comment

spaNavMaxStep const vs. template literal "3"handlers_navigation.go defines spaNavMaxStep = 3, but the template hardcodes Step {{.Step}} of 3. If the constant ever changes, the template won't follow. Consider passing max step through the state struct (SPANavState.MaxStep) so the template can render of {{.MaxStep}}.


Auto-created by prmonitor from PR review comments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-upFollow-up task from PR reviewfrom-reviewIssue originated from PR review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions