Skip to content

Query editor mouse events swallowed by autocomplete panel background #1831

Closed

Description

@yankewei

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

  1. Open a query tab and start typing SQL to trigger autocomplete (e.g. type SEL or SELECT * FROM ).
  2. Wait for the autocomplete panel to appear.
  3. Click on the panel's background, vertical padding, or rounded corner area — not on a suggestion row.
  4. 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

  1. LocalPackages/CodeEditSourceEditor/Sources/CodeEditSourceEditor/CodeSuggestion/Model/SuggestionViewModel.swift

    • Add var onBackgroundTap: (() -> Void)?.
  2. LocalPackages/CodeEditSourceEditor/Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController.swift

    • In init(), set model.onBackgroundTap = { [weak self] in self?.close() }.
  3. LocalPackages/CodeEditSourceEditor/Sources/CodeEditSourceEditor/CodeSuggestion/View/SuggestionContentView.swift

    • Wrap the .background(Color(nsColor: model.themeBackground)) with .contentShape(Rectangle()).onTapGesture { model.onBackgroundTap?() }.
  4. LocalPackages/CodeEditSourceEditor/Tests/CodeEditSourceEditorTests/CodeSuggestion/SuggestionApplyTests.swift

    • Add a test that calling model.onBackgroundTap?() clears the controller's model state.
  5. CHANGELOG.md

    • Add a note under [Unreleased] > Fixed.

Notes

  • This keeps list-row selection intact because row-level .onTapGesture modifiers 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

  1. yankewei commented on Jul 8, 2026

    @yankewei
    ContributorAuthor

    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 NSPanel ordered 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 to editorFrame; 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:

    1. The background-tap dismissal described above.
    2. Horizontal constraint relative to editorFrame so the panel does not extend over the right-side toolbar/status bar.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions