Skip to content

Commit ae84d6e

Browse files
committed
fix(input-accessory): ensure scroll edge is used on ios 26+
1 parent 6a17e40 commit ae84d6e

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

packages/input-accessory/platforms/ios/src/KeyboardTrackingView.swift

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,7 @@ public class KeyboardTrackingView: UIView {
141141

142142
self._keyboardAccessoryView = accessoryContainer
143143

144-
// On iOS 26+, add scroll edge blending so the bottom of the ScrollView
145-
// fades into the glass accessory (like Apple Notes / iMessage).
146-
if #available(iOS 26.0, *) {
147-
let edgeInteraction = UIScrollEdgeElementContainerInteraction()
148-
edgeInteraction.scrollView = scrollView
149-
edgeInteraction.edge = .bottom
150-
accessoryContainer.addInteraction(edgeInteraction)
151-
}
144+
addScrollEdgeElementContainerInteractionIfAvailable(to: accessoryContainer, scrollView: scrollView)
152145

153146
// Set up scroll view for interactive dismiss
154147
scrollView.keyboardDismissMode = .interactive
@@ -176,6 +169,26 @@ public class KeyboardTrackingView: UIView {
176169
self?.becomeFirstResponder()
177170
}
178171
}
172+
173+
private func addScrollEdgeElementContainerInteractionIfAvailable(to containerView: UIView, scrollView: UIScrollView) {
174+
guard #available(iOS 26.0, *) else { return }
175+
176+
// UIScrollEdgeElementContainerInteraction is an iOS 26 SDK symbol. Resolve
177+
// it dynamically so the plugin still compiles with Xcode 16.x / iOS 18.x SDKs.
178+
let interactionClass = (
179+
NSClassFromString("UIScrollEdgeElementContainerInteraction")
180+
?? NSClassFromString("UIKit.UIScrollEdgeElementContainerInteraction")
181+
) as? NSObject.Type
182+
183+
guard let interactionClass = interactionClass else { return }
184+
185+
let interaction = interactionClass.init()
186+
interaction.setValue(scrollView, forKey: "scrollView")
187+
interaction.setValue(NSNumber(value: UIRectEdge.bottom.rawValue), forKey: "edge")
188+
189+
guard let edgeInteraction = interaction as? UIInteraction else { return }
190+
containerView.addInteraction(edgeInteraction)
191+
}
179192

180193
/**
181194
* Set the callback for relayouting ScrollView content

0 commit comments

Comments
 (0)