Skip to content

fix: single-click on sidebar table only toggles columns, not a new tab (#54)#178

Merged
eugene-mobile merged 1 commit into
mainfrom
fix/sidebar-single-click-table
Jun 14, 2026
Merged

fix: single-click on sidebar table only toggles columns, not a new tab (#54)#178
eugene-mobile merged 1 commit into
mainfrom
fix/sidebar-single-click-table

Conversation

@eugene-mobile

Copy link
Copy Markdown
Contributor

Problem

Closes #54. Single-clicking a table name in the schema browser both expanded/collapsed its column list and opened (or switched to) a SELECT * FROM table LIMIT 100; query tab. Users who just wanted to peek at column names were unintentionally navigated away from their current editor work.

Fix

In SchemaBrowser.tsx, the table row's click handling is split:

  • Single-click → toggles the column list expand/collapse only (toggleTable). It no longer touches the active tab or onTableSelect.
  • Double-click → opens the query tab (onTableSelect), the deliberate action.
  • Right-click → "Query table" → a new context-menu item, same deliberate onTableSelect path, for discoverability.

The hover tooltip now hints "double-click to query".

onTableSelect itself is unchanged, so the existing behaviour it drives is preserved: dedupe by (schema, table) so re-querying a table reuses its tab, and the PK-aware SELECT template (descending sort only for a single auto-increment PK).

Notes

  • Double-clicking fires two onClicks (toggle → toggle) before onDoubleClick, so expansion nets to its prior state while the tab opens — the standard tree-view trade-off, visually negligible.
  • No behaviour test added: the repo has no component-test infra (no jsdom/RTL, vitest only matches .test.ts) and no existing SchemaBrowser tests. The change is pure handler rewiring; typecheck, lint, and the production build pass, and the existing 76 client tests are green.

Per request, the app was not launched for manual verification.

🤖 Generated with Claude Code

#54)

Single-clicking a table in the schema browser used to both expand/collapse
its column list and open (or switch to) a SELECT query tab, navigating users
away from unsaved work just for wanting to peek at column names.

Single-click now only toggles the column list. Opening a query tab is a
deliberate action: double-click the table, or pick "Query table" from the
right-click context menu (both call the existing onTableSelect path, so the
dedupe-by-(schema,table) and PK-aware template behaviour is unchanged).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@eugene-mobile

Copy link
Copy Markdown
Contributor Author

@claude review this PR

@claude

claude Bot commented Jun 14, 2026

Copy link
Copy Markdown

Claude finished @eugene-mobile's task in 1m 40s —— View job


PR Review

  • Gather context (diff, changed files)
  • Analyze the changes
  • Post review feedback

Overall: Looks good — clean, well-scoped fix. The change is small and the PR description is unusually thorough in explaining trade-offs. A few observations below.


What works well

  • The three paths to open a query tab (double-click, context menu, and external callers of onTableSelect) are correctly wired up and the prop interface (onTableSelect: (name: string) => void) is required, so no null-guard is needed on the double-click handler.
  • Placing "Query table" before "Edit table" / "Drop table" in the context menu is the right ordering (least-impact → most-impact).
  • The title tooltip distinguishing the no-comment and with-comment cases is clean:
    ? `${table.comment} — double-click to query` : 'Double-click to query'}

Minor observations

1. Comment verbosity (SchemaBrowser.tsx:253-256)

The 4-line block comment is more than this codebase's style needs. The "why" is that single-click used to steal focus — one line with the issue reference covers it:

// Expand/collapse only — opening a query tab is deliberate (double-click or ctx menu). See #54.
onClick={() => toggleTable(table.name)}

Fix this →

2. Double-click toggle flicker (acknowledged, trade-off accepted)

The PR description correctly notes that dblclick fires as click → click → dblclick, so two toggleTable calls cancel each other out. The state is preserved but the row will visually collapse-then-expand (or vice versa) briefly. The standard workaround — deferring onClick with setTimeout(250ms) to cancel on double-click — adds 250ms latency to every expand, which is a worse trade-off for a schema browser. The current approach is the pragmatic call.

3. activeTable highlight no longer reflects single-click

Before this change, single-clicking highlighted the row (activeTable === table.nametableRowActive). Now the highlight only updates on double-click/context menu. This is correct given the fix intent — but worth confirming the activeTable highlight still correctly tracks the open query tab (i.e., is set by onTableSelect and flows back down as a prop).


No blocking issues. The double-click flicker and discoverability trade-offs are called out honestly in the PR description. The comment verbosity is the only thing worth tightening before merge.

@eugene-mobile eugene-mobile merged commit ad4a76a into main Jun 14, 2026
1 check passed
@eugene-mobile eugene-mobile deleted the fix/sidebar-single-click-table branch June 14, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single-click on table in sidebar unexpectedly opens a new query tab

1 participant