Skip to content

Commit 399868b

Browse files
authored
Fix/beta 1.0 (#25)
* fix: working dentent setting and improved performance * fix: bring back the keyboard avoidance hack * fix: improve example code with viewbuilder * fix: improved keyboard avoidance setup
1 parent e917aea commit 399868b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Sources/BottomSheet/Preference Keys/ConfigKey.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ struct SheetPlusKey: PreferenceKey {
2222
static var defaultValue: SheetPlusConfig = SheetPlusConfig(detents: [], selectedDetent: .constant(.height(.zero)), translation: 0)
2323

2424
static func reduce(value: inout SheetPlusConfig, nextValue: () -> SheetPlusConfig) {
25-
value = nextValue()
25+
/// This prevents the translation changes to be called whenever the keyboard is triggered.
26+
/// If the keyboard gets triggered it will also reset the whole configkey and losing the binding.
27+
/// https://stackoverflow.com/questions/67644164/preferencekey-issue-swiftui-sometimes-seems-to-generate-additional-views-that
28+
value = nextValue() != defaultValue ? nextValue() : value
2629
}
2730
}

0 commit comments

Comments
 (0)