Repository navigation
Description
What happened?
In the SQL query editor, the mouse frequently becomes unresponsive after the autocomplete panel appears. Clicks that should place the cursor, select text, or open the context menu (copy/paste) are lost when they land on the autocomplete panel's background, padding, or rounded corners instead of reaching the editor.
This appears to be a remaining edge case after the #1815 fix, which added a local mouse monitor that only dismisses the panel when the click is outside the panel's frame. Clicks that fall inside the panel frame but outside the actual suggestion items are still routed to the panel window and swallowed.
Steps to reproduce
- Open a query tab and start typing SQL to trigger autocomplete (e.g. type
SELorSELECT * FROM). - Wait for the autocomplete panel to appear.
- Click on the panel's background, vertical padding, or rounded corner area — not on a suggestion row.
- Observe that the panel does not dismiss and the editor does not receive the click.
Expected behavior
Clicking any non-interactive area of the autocomplete panel should dismiss it and return mouse control to the editor.
Root cause
SuggestionController shows the autocomplete list in a child NSPanel ordered above the editor window (SuggestionPanel, level .popUpMenu). The local mouse monitor added in #1815 closes the panel only when event.window !== panel. When the click lies inside the panel frame, AppKit routes the event to the panel window; the monitor returns the event unchanged, and the panel's transparent background swallows it. The editor text view never sees the click.
Suggested fix
Add a background tap gesture to the SwiftUI content so that taps on non-interactive areas of the panel call back to the controller and close the panel.
Files to change
-
LocalPackages/CodeEditSourceEditor/Sources/CodeEditSourceEditor/CodeSuggestion/Model/SuggestionViewModel.swift- Add
var onBackgroundTap: (() -> Void)?.
- Add
-
LocalPackages/CodeEditSourceEditor/Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController.swift- In
init(), setmodel.onBackgroundTap = { [weak self] in self?.close() }.
- In
-
LocalPackages/CodeEditSourceEditor/Sources/CodeEditSourceEditor/CodeSuggestion/View/SuggestionContentView.swift- Wrap the
.background(Color(nsColor: model.themeBackground))with.contentShape(Rectangle()).onTapGesture { model.onBackgroundTap?() }.
- Wrap the
-
LocalPackages/CodeEditSourceEditor/Tests/CodeEditSourceEditorTests/CodeSuggestion/SuggestionApplyTests.swift- Add a test that calling
model.onBackgroundTap?()clears the controller's model state.
- Add a test that calling
-
CHANGELOG.md- Add a note under
[Unreleased] > Fixed.
- Add a note under
Notes
- This keeps list-row selection intact because row-level
.onTapGesturemodifiers take precedence over the parent background gesture. - This fix dismisses the panel on background clicks; placing the cursor at the clicked location will require a second click, which matches the standard autocomplete UX and the intent of Fix reported data grid, editor, and filter UX issues #1815.
Activity
yankewei commentedon Jul 8, 2026
Update after more user feedback: the problem is not limited to the query editor text area. The buttons shown in the screenshot (bottom-right toolbar/status-bar area: refresh/undo, apply/save, search, add, visibility) are also unclickable when the autocomplete panel appears.
This suggests the suggestion panel is still overlapping those buttons in some cursor positions / window layouts, even though #1815 attempted to constrain it to the editor bounds. Because the panel is a child
NSPanelordered above the editor window, any click that lands inside the panel frame is routed to the panel and swallowed, so the underlying buttons never receive the event.The background-tap fix proposed above remains a good mitigation: clicking anywhere on the panel's non-interactive background would close it and restore access to the overlapped buttons. However, it may also be worth reviewing the panel's horizontal positioning logic in
constrainWindowToScreenEdges— currently only the vertical position is constrained relative toeditorFrame; the horizontal position is only constrained to the screen. If the cursor is in the right half of the editor, the panel can extend rightward and cover the bottom-right buttons.A more complete fix could combine:
editorFrameso the panel does not extend over the right-side toolbar/status bar.