Skip to content

Commit 52b7b5c

Browse files
committed
refactor: remove debug console logs from NodeOptions
1 parent 9c90a05 commit 52b7b5c

File tree

1 file changed

+25
-39
lines changed

1 file changed

+25
-39
lines changed

src/components/graph/selectionToolbox/NodeOptions.vue

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -119,53 +119,19 @@ const { results } = useFuse(debouncedSearchQuery, searchableMenuOptions, {
119119
matchAllWhenSearchEmpty: true
120120
})
121121
122-
// Debug logging
123-
watch(searchQuery, (newVal) => {
124-
console.warn('[NodeOptions] searchQuery changed:', newVal)
125-
})
126-
127-
watch(debouncedSearchQuery, (newVal) => {
128-
console.warn('[NodeOptions] debouncedSearchQuery changed:', newVal)
129-
})
130-
131-
watch(results, (newVal) => {
132-
console.warn('[NodeOptions] useFuse results:', newVal)
133-
console.warn('[NodeOptions] results count:', newVal.length)
134-
if (newVal.length > 0) {
135-
console.warn('[NodeOptions] first result:', newVal[0])
136-
}
137-
})
138-
139-
watch(searchableMenuOptions, (newVal) => {
140-
console.warn('[NodeOptions] searchableMenuOptions:', newVal)
141-
console.warn('[NodeOptions] searchableMenuOptions count:', newVal.length)
142-
})
143-
144122
// Filter menu options based on fuzzy search results
145123
const filteredMenuOptions = computed(() => {
146124
const query = debouncedSearchQuery.value.trim()
147-
console.warn('[NodeOptions] filteredMenuOptions computed - query:', query)
148-
console.warn(
149-
'[NodeOptions] filteredMenuOptions computed - results.value:',
150-
results.value
151-
)
152125
153126
if (!query) {
154-
console.warn(
155-
'[NodeOptions] No query, returning all menuOptions:',
156-
menuOptions.value.length
157-
)
158127
return menuOptions.value
159128
}
160129
161130
// Extract matched items from Fuse results and create a Set of labels for fast lookup
162131
const matchedItems = results.value.map((result) => result.item)
163-
console.warn('[NodeOptions] matchedItems:', matchedItems)
164-
console.warn('[NodeOptions] matchedItems count:', matchedItems.length)
165132
166133
// Create a Set of matched labels for O(1) lookup
167134
const matchedLabels = new Set(matchedItems.map((item) => item.label))
168-
console.warn('[NodeOptions] matchedLabels:', Array.from(matchedLabels))
169135
170136
const filtered: MenuOption[] = []
171137
let lastWasDivider = false
@@ -195,8 +161,6 @@ const filteredMenuOptions = computed(() => {
195161
}
196162
}
197163
198-
console.warn('[NodeOptions] final filtered results:', filtered)
199-
console.warn('[NodeOptions] final filtered count:', filtered.length)
200164
return filtered
201165
})
202166
@@ -283,7 +247,9 @@ function openPopover(
283247
clickedFromToolbox?: boolean
284248
): boolean {
285249
const el = element || targetElement.value
286-
if (!el || !el.isConnected) return false
250+
if (!el || !el.isConnected) {
251+
return false
252+
}
287253
targetElement.value = el
288254
if (clickedFromToolbox !== undefined)
289255
isTriggeredByToolbox.value = clickedFromToolbox
@@ -335,8 +301,28 @@ const toggle = (
335301
element?: HTMLElement,
336302
clickedFromToolbox?: boolean
337303
) => {
338-
if (isOpen.value) closePopover('manual')
339-
else openPopover(event, element, clickedFromToolbox)
304+
const targetEl = element || targetElement.value
305+
306+
if (isOpen.value) {
307+
// If clicking on a different element while open, switch to it
308+
if (targetEl && targetEl !== targetElement.value) {
309+
// Update target and reposition, don't close and reopen
310+
targetElement.value = targetEl
311+
if (clickedFromToolbox !== undefined)
312+
isTriggeredByToolbox.value = clickedFromToolbox
313+
bump()
314+
// Clear and refocus search for new context
315+
searchQuery.value = ''
316+
requestAnimationFrame(() => {
317+
repositionPopover()
318+
searchInput.value?.focus()
319+
})
320+
} else {
321+
closePopover('manual')
322+
}
323+
} else {
324+
openPopover(event, element, clickedFromToolbox)
325+
}
340326
}
341327
342328
const hide = (reason: HideReason = 'manual') => closePopover(reason)

0 commit comments

Comments
 (0)