Skip to content

Commit

Permalink
fix max width logic (#40)
Browse files Browse the repository at this point in the history
To ensure the form is no greater than maxWidth, we need to take the minimum among the desired width and maxWidth.

Taking the maximum among these values effectively changes the logic to ensure the form is no less than maxWidth (in which case, it should probably be called minWidth).
  • Loading branch information
ardnew authored Dec 11, 2023
1 parent 1b4709b commit fc15d38
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/bubbletea/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (m Model) Init() tea.Cmd {
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.WindowSizeMsg:
m.width = max(msg.Width, maxWidth) - m.styles.Base.GetHorizontalFrameSize()
m.width = min(msg.Width, maxWidth) - m.styles.Base.GetHorizontalFrameSize()
case tea.KeyMsg:
switch msg.String() {
case "esc", "ctrl+c", "q":
Expand Down

0 comments on commit fc15d38

Please sign in to comment.