Open
Conversation
Signed-off-by: DharunMR <maddharun56@gmail.com>
Signed-off-by: DharunMR <maddharun56@gmail.com>
Contributor
|
Thanks for the fix, this addresses the root cause (using a page-relative index with SetItem caused the wrong item to be toggled). Before it is reviewed and merged by @evankanderson, please make 2 small improvements and update the PR description/tests:
Suggested message to include in your PR and a minimal code example to apply in internal/util/cli/multi_select.go: // Add a stable id field to the item if not already present:
type item struct {
id string // e.g. repo full name or repo ID
title string
checked bool
}
// In the space-key handler, find by id and handle not-found:
var absoluteIdx int
found := false
for i, listItem := range m.list.Items() {
if listItem.(item).id == oldItem.id {
absoluteIdx = i
found = true
break
}
}
if !found {
// safe fallback: log or ignore the toggle to avoid out-of-range errors
return m, nil
}
cmd := m.list.SetItem(absoluteIdx, item{
id: oldItem.id,
title: oldItem.title,
checked: !oldItem.checked,
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a state management bug in the
minder repo registercommand where selecting a repository while a search filter is active causes UI duplication and incorrect state updates.The issue stemmed from using
m.list.Index()which returns the index of the item relative to the currently visible filtered list. When a filter is active this index does not match the item position in the underlying data slice. Passing this relative index tom.list.SetItem()caused the wrong record in the base data to be overwritten or duplicated.Fixes #5051
After Changes