Skip to content

Commit 1169412

Browse files
committed
fix: filter sheet cancel reverts changes — use local draft state, add CHANGELOG
1 parent 95aadc3 commit 1169412

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- iOS: connection groups and tags
1313
- iOS: Quick Connect Home Screen widget
1414
- iOS: page-based pagination for data browser
15+
- iOS: filter bar with 16 operators, AND/OR logic
1516

1617
## [0.27.4] - 2026-04-05
1718

TableProMobile/TableProMobile/Views/DataBrowserView.swift

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -420,25 +420,32 @@ private struct FilterSheetView: View {
420420
let onApply: () -> Void
421421
let onClear: () -> Void
422422

423+
@State private var draft: [TableFilter] = []
424+
@State private var draftLogicMode: FilterLogicMode = .and
425+
426+
private var hasValidFilters: Bool {
427+
draft.contains { $0.isEnabled && $0.isValid }
428+
}
429+
423430
private func bindingForFilter(_ id: UUID) -> Binding<TableFilter>? {
424-
guard let index = filters.firstIndex(where: { $0.id == id }) else { return nil }
425-
return $filters[index]
431+
guard let index = draft.firstIndex(where: { $0.id == id }) else { return nil }
432+
return $draft[index]
426433
}
427434

428435
var body: some View {
429436
NavigationStack {
430437
Form {
431-
if filters.count > 1 {
438+
if draft.count > 1 {
432439
Section {
433-
Picker("Logic", selection: $logicMode) {
440+
Picker("Logic", selection: $draftLogicMode) {
434441
Text("AND").tag(FilterLogicMode.and)
435442
Text("OR").tag(FilterLogicMode.or)
436443
}
437444
.pickerStyle(.segmented)
438445
}
439446
}
440447

441-
ForEach(filters) { filter in
448+
ForEach(draft) { filter in
442449
if let binding = bindingForFilter(filter.id) {
443450
Section {
444451
Picker("Column", selection: binding.columnName) {
@@ -468,20 +475,22 @@ private struct FilterSheetView: View {
468475
}
469476
}
470477
.onDelete { indexSet in
471-
filters.remove(atOffsets: indexSet)
478+
draft.remove(atOffsets: indexSet)
472479
}
473480

474481
Section {
475482
Button {
476-
filters.append(TableFilter(columnName: columns.first?.name ?? ""))
483+
draft.append(TableFilter(columnName: columns.first?.name ?? ""))
477484
} label: {
478485
Label("Add Filter", systemImage: "plus.circle")
479486
}
480487
}
481488

482-
if !filters.isEmpty {
489+
if !draft.isEmpty {
483490
Section {
484491
Button("Clear All Filters", role: .destructive) {
492+
filters.removeAll()
493+
logicMode = .and
485494
onClear()
486495
dismiss()
487496
}
@@ -496,12 +505,18 @@ private struct FilterSheetView: View {
496505
}
497506
ToolbarItem(placement: .confirmationAction) {
498507
Button("Apply") {
508+
filters = draft
509+
logicMode = draftLogicMode
499510
onApply()
500511
dismiss()
501512
}
502-
.disabled(!filters.contains { $0.isEnabled && $0.isValid })
513+
.disabled(!hasValidFilters)
503514
}
504515
}
516+
.onAppear {
517+
draft = filters
518+
draftLogicMode = logicMode
519+
}
505520
}
506521
}
507522
}

0 commit comments

Comments
 (0)