Skip to content

Commit 5227b7c

Browse files
authored
fix(editor): size the query error banner to its message instead of a fixed height (#1834)
1 parent 5de84ec commit 5227b7c

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Switching schemas on an Oracle connection no longer hangs on an infinite loading spinner. Oracle now switches by schema like BigQuery, the sidebar lists every schema with its tables loading on expand, Oracle queries respect the query timeout setting and reconnect automatically after a timeout, and a schema load that fails shows an error with a Retry button instead of spinning forever. Works with an already-installed Oracle plugin; updating the plugin adds the query timeout enforcement. (#1807)
3333
- Resizing a data grid column no longer triggers a sort. Dragging a column edge only resizes it; clicking the header still sorts. (#1815)
3434
- Hidden columns stay hidden. The columns you choose to show are remembered per table across sessions, and resizing a column no longer brings the hidden ones back. Column widths and order are remembered per table too, now kept separately for each connection, database, and schema so two tables with the same name no longer overwrite each other's layout. A Reset Columns button in the Columns popover puts widths, order, and visibility back to defaults. Existing saved column layouts (widths, order, and which columns are hidden) reset once as part of this change. (#1815)
35-
- Query and filter errors now appear in a scrollable banner you can read, select, and copy, with a Fix with AI button, instead of a small dialog that cut the message off. (#1815)
35+
- Query and filter errors now appear in a banner you can read, select, and copy, with a Fix with AI button, instead of a small dialog that cut the message off. The banner sizes to the message, staying a single line for short errors and scrolling only when the message is long. (#1815)
3636
- The filter autocomplete no longer pops up on empty input, and pressing Escape to close it no longer also closes the filter bar. (#1815)
3737
- The editor autocomplete popup no longer draws over the status bar, the Columns and Add buttons, or the editor's sides as it grows. Clicking anywhere on the popup that isn't a suggestion now dismisses it, instead of doing nothing and leaving the editor mouse dead. (#1815, #1831)
3838

TablePro/Views/Results/InlineErrorBanner.swift

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ struct InlineErrorBanner: View {
1313
var onFixWithAI: (() -> Void)?
1414
var onDismiss: (() -> Void)?
1515

16+
private let maxMessageHeight: CGFloat = 96
17+
@State private var messageHeight: CGFloat = 0
18+
19+
private var messageFits: Bool { messageHeight <= maxMessageHeight }
20+
1621
var body: some View {
1722
HStack(alignment: .top, spacing: 8) {
1823
Image(systemName: "exclamationmark.triangle.fill")
@@ -22,8 +27,15 @@ struct InlineErrorBanner: View {
2227
.font(.subheadline)
2328
.textSelection(.enabled)
2429
.frame(maxWidth: .infinity, alignment: .leading)
30+
.onGeometryChange(for: CGFloat.self) { proxy in
31+
proxy.size.height
32+
} action: { height in
33+
messageHeight = height
34+
}
2535
}
26-
.frame(maxHeight: 96)
36+
.frame(height: min(messageHeight, maxMessageHeight))
37+
.scrollDisabled(messageFits)
38+
.scrollBounceBehavior(.basedOnSize)
2739
if let onFixWithAI {
2840
Button(String(localized: "Fix with AI")) { onFixWithAI() }
2941
.controlSize(.small)
@@ -55,9 +67,17 @@ struct InlineErrorBanner: View {
5567
}
5668

5769
#Preview {
58-
InlineErrorBanner(
59-
message: "ERROR 1064 (42000): You have an error in your SQL syntax",
60-
onDismiss: {}
61-
)
70+
VStack(spacing: 0) {
71+
InlineErrorBanner(message: "near \"Album\": syntax error", onDismiss: {})
72+
Divider()
73+
InlineErrorBanner(
74+
message: String(
75+
repeating: "ERROR 1064 (42000): You have an error in your SQL syntax near this token. ",
76+
count: 8
77+
),
78+
onFixWithAI: {},
79+
onDismiss: {}
80+
)
81+
}
6282
.frame(width: 600)
6383
}

0 commit comments

Comments
 (0)