Skip to content

Commit

Permalink
Fix null reference when window is null
Browse files Browse the repository at this point in the history
When using certain controls ie bottom sheets and search bars there can be a crash when the keyboard displays. Check for null & return early if it is.
  • Loading branch information
Axemasta committed Apr 10, 2024
1 parent 8410edb commit 4cc9f61
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* This class is adapted from IQKeyboardManager which is an open-source
* library implemented for iOS to handle Keyboard interactions with
* UITextFields/UITextViews. Link to their MIT License can be found here:
Expand Down Expand Up @@ -309,7 +309,12 @@ internal static void AdjustPosition()
TopViewBeginOrigin = new CGPoint(ContainerView.Frame.X, ContainerView.Frame.Y);

var rootViewOrigin = new CGPoint(ContainerView.Frame.GetMinX(), ContainerView.Frame.GetMinY());
var window = ContainerView.Window;
var window = ContainerView?.Window;

if (window is null)
{
return;
}

var intersectRect = CGRect.Intersect(KeyboardFrame, window.Frame);
var kbSize = intersectRect == CGRect.Empty ? new CGSize(KeyboardFrame.Width, 0) : intersectRect.Size;
Expand Down

0 comments on commit 4cc9f61

Please sign in to comment.