| 139 | } |
| 140 | |
| 141 | func TestMenu_MinWidthFloorForShortcuts(t *testing.T) { |
| 142 | menu := NewMenu( |
| 143 | MenuItem{Label: "Stop", Key: 0, Shortcut: WithHelp(NewKeyBinding("s"), "s", "")}, |
| 144 | MenuItem{Label: "Remove", Key: 1, Shortcut: WithHelp(NewKeyBinding("r"), "r", "")}, |
| 145 | ) |
| 146 | // Set width narrower than content needs — minWidth should be used |
| 147 | menu.SetWidth(3) |
| 148 | |
| 149 | view := ansi.Strip(menu.View()) |
| 150 | lines := strings.Split(view, "\n") |
| 151 | |
| 152 | // Both keys should be consistently right-aligned |
| 153 | assert.True(t, strings.HasSuffix(lines[0], "s")) |
| 154 | assert.True(t, strings.HasSuffix(lines[1], "r")) |
| 155 | assert.Equal(t, lipgloss.Width(lines[0]), lipgloss.Width(lines[1])) |
| 156 | } |