Skip to content

Commit

Permalink
Ensure init is run before updating with WindowSizeMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Miller committed Apr 11, 2024
1 parent 745183a commit 742e09e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions navstack/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ func (m *Model) Push(item NavigationItem) tea.Cmd {
}
}

initCmd := item.Init()

wmsg := m.window.GetWindowSizeMsg()
nim, cmd := item.Model.Update(wmsg)
nim, winCmd := item.Model.Update(wmsg)
item.Model = nim

m.stack = append(m.stack, item)
return tea.Batch(cmd, item.Init())
return tea.Sequence(initCmd, winCmd)
}

// Pop removes the top most navigation item from the stack.
Expand All @@ -87,12 +89,11 @@ func (m *Model) Pop() tea.Cmd {
return tea.Quit
}

cmds := []tea.Cmd{}
nim, cmd := top.Model.Update(m.window.GetWindowSizeMsg())
initCmd := top.Init()
nim, winCmd := top.Model.Update(m.window.GetWindowSizeMsg())
top.Model = nim
cmds = append(cmds, cmd, top.Init())

return tea.Batch(cmds...)
return tea.Sequence(winCmd, initCmd)
}

// Clear pops all the items from the stack.
Expand Down

0 comments on commit 742e09e

Please sign in to comment.