Handle keyboard and orientation changes smoother#540
Handle keyboard and orientation changes smoother#540belleklaviyo wants to merge 2 commits intofeat/flyouts-formsfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| private var window: UIWindow? | ||
| private var windowScene: UIWindowScene? | ||
| private var currentLayout: FormLayout? | ||
| private weak var viewController: KlaviyoWebViewController? |
There was a problem hiding this comment.
Property viewController is set but never read
Low Severity
The new private weak var viewController property is assigned in present() on line 26 via self.viewController = viewController but is never read anywhere in the class. All other references to viewController in the file (lines 39, 47, 129, 131) resolve to local method parameters, not the instance property. This is a dead store. It may have been intended for cleanup in dismiss() (e.g., clearing onSizeTransition), but that line was never added.
Additional Locations (1)
There was a problem hiding this comment.
This feels legit. Do we need it if it's not read? Or maybe it's read and this is wrong.
| window.frame = adjustedFrame | ||
| } else { | ||
| window.frame = baseFrame | ||
| } |
There was a problem hiding this comment.
Fullscreen forms shift off-screen when keyboard appears
High Severity
Removing the isBottomAnchored gate without exempting .fullscreen forms means fullscreen forms now participate in the keyboard overlap check. For fullscreen, calculateFrame returns screenBounds, so gap is always zero and overlap equals the full keyboardHeight. The window gets shifted to a negative y-origin (e.g., y = −336), clipping the top of the form off-screen. Fullscreen is the default layout (seen in IAFWebViewModel.swift), so this affects many forms. The old code correctly skipped keyboard adjustment for non-bottom-anchored positions including fullscreen.
|
Unrelated but maybe we have to deal with x moving on orientation oof. |
ndurell
left a comment
There was a problem hiding this comment.
Based on the video looks ok to me. Not sure if it applies but might be good to rest with fullscreen.
|
|
||
| private func setupObservers() { | ||
| NotificationCenter.default.addObserver(self, selector: #selector(handleOrientationChange), name: UIDevice.orientationDidChangeNotification, object: nil) | ||
| private func setupObservers(on viewController: KlaviyoWebViewController) { |
There was a problem hiding this comment.
Do any of these changes affect full screen forms?


Description
Fixes two issues with in-app form window positioning: orientation changes were not animating smoothly, and keyboard avoidance was incorrectly applied to all bottom-anchored forms regardless of actual overlap.
Due Diligence
Release/Versioning Considerations
PatchContains internal changes or backwards-compatible bug fixes.MinorContains changes to the public API.MajorContains breaking changes.Changelog / Code Overview
Orientation handling
UIDevice.orientationDidChangeNotificationwithviewWillTransition(to:with:)via a newonSizeTransitioncallback onKlaviyoWebViewControllerKeyboard avoidance
isBottomAnchoredgate so all form positions participate in the overlap checkTest Plan
Simulator.Screen.Recording.-.iOS.18.-.2026-04-03.at.15.45.02.mov
Related Issues/Tickets