mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-26 15:07:39 +00:00
Fix mouse hover selection in autocomplete dropdown
- Pass selectedIndex binding through to AutocompleteViewWithKeyboard - Allow mouse hover to properly update selection state - Maintain keyboard navigation functionality
This commit is contained in:
parent
b7aafa9a6d
commit
f893e747a5
1 changed files with 6 additions and 4 deletions
|
|
@ -31,7 +31,7 @@ struct AutocompleteWindowView: NSViewRepresentable {
|
|||
}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
Coordinator(onSelect: onSelect, isShowing: $isShowing)
|
||||
Coordinator(onSelect: onSelect, isShowing: $isShowing, selectedIndex: $selectedIndex)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
|
|
@ -40,11 +40,13 @@ struct AutocompleteWindowView: NSViewRepresentable {
|
|||
private var hostingView: NSHostingView<AnyView>?
|
||||
private let onSelect: (String) -> Void
|
||||
@Binding var isShowing: Bool
|
||||
@Binding var selectedIndex: Int
|
||||
nonisolated(unsafe) private var clickMonitor: Any?
|
||||
|
||||
init(onSelect: @escaping (String) -> Void, isShowing: Binding<Bool>) {
|
||||
init(onSelect: @escaping (String) -> Void, isShowing: Binding<Bool>, selectedIndex: Binding<Int>) {
|
||||
self.onSelect = onSelect
|
||||
self._isShowing = isShowing
|
||||
self._selectedIndex = selectedIndex
|
||||
super.init()
|
||||
}
|
||||
|
||||
|
|
@ -99,11 +101,11 @@ struct AutocompleteWindowView: NSViewRepresentable {
|
|||
guard let window = dropdownWindow,
|
||||
let hostingView = hostingView else { return }
|
||||
|
||||
// Update content
|
||||
// Update content with proper binding
|
||||
let content = VStack(spacing: 0) {
|
||||
AutocompleteViewWithKeyboard(
|
||||
suggestions: suggestions,
|
||||
selectedIndex: .constant(selectedIndex),
|
||||
selectedIndex: $selectedIndex,
|
||||
keyboardNavigating: keyboardNavigating
|
||||
) { [weak self] suggestion in
|
||||
self?.onSelect(suggestion)
|
||||
|
|
|
|||
Loading…
Reference in a new issue