Skip to content

Commit cea0a19

Browse files
committed
fix(tui): prevent extra row appearing in blocking picker on toggle
Create a new slice when updating items instead of modifying the slice returned by list.Items() in place, which was corrupting internal state.
1 parent f695195 commit cea0a19

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

internal/tui/blockingpicker.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,18 @@ func (m blockingPickerModel) Update(msg tea.Msg) (blockingPickerModel, tea.Cmd)
209209
}
210210

211211
// Update the list items to reflect new state
212-
items := m.list.Items()
213-
for i, listItem := range items {
212+
oldItems := m.list.Items()
213+
newItems := make([]list.Item, len(oldItems))
214+
for i, listItem := range oldItems {
214215
if bi, ok := listItem.(blockingItem); ok {
215-
items[i] = blockingItem{
216+
newItems[i] = blockingItem{
216217
bean: bi.bean,
217218
cfg: bi.cfg,
218219
isBlocking: m.pendingBlocking[bi.bean.ID],
219220
}
220221
}
221222
}
222-
m.list.SetItems(items)
223+
m.list.SetItems(newItems)
223224

224225
// Restore selection position
225226
m.list.Select(currentIndex)

0 commit comments

Comments
 (0)