Skip to content

Commit 4fd8550

Browse files
committed
- fixed an issue when the heightConstraint receives an infinite value
1 parent 30b2942 commit 4fd8550

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/KeyboardLayoutGuide/KeyboardLayoutGuide.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,16 @@ open class KeyboardLayoutGuide: UILayoutGuide {
122122
let intersectionFrame = activeWindow.frame.intersection(owningFrameInRoot)
123123

124124
let windowHeight = activeWindow.frame.height
125-
let bottomDifference = windowHeight - (intersectionFrame.height + intersectionFrame.origin.y)
125+
let bottomDifference = windowHeight - intersectionFrame.maxY
126126

127127
height -= bottomDifference
128128
}
129129

130-
130+
guard height != .infinity else {
131+
// When the app is running in multiple windows, it can happen that both windows are `foregroundActive`
132+
// and the intersection frame's origin can become infinite as the owning view is in the other window and the app would crash.
133+
return
134+
}
131135
heightConstraint?.constant = height
132136
if duration > 0.0 {
133137
animate(note)

0 commit comments

Comments
 (0)