fix viewport not resetting when keyboard dismisses

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Fabian Freund
2026-02-14 20:38:10 +01:00
co-authored by Claude Opus 4.6
parent 24b8eb7057
commit fbbf331057
@@ -418,19 +418,15 @@ class BrowserScreen extends HookConsumerWidget {
useOnStreamChange(
viewportService.keyboardEvents,
onData: (event) {
if (event.isVisible && event.heightPx > 0) {
// When keyboard is visible, notify GeckoView to adjust viewport
// This uses the native API to handle keyboard without Flutter resize
// If find-in-page is also visible, add its height to the keyboard height
final findInPageHeightPx = findInPageVisible
? (FindInPageWidget.findInPageHeight * pixelRatio).round()
: 0;
unawaited(
viewportService.setDynamicToolbarMaxHeight(
event.heightPx + findInPageHeightPx,
),
);
}
// When keyboard is visible, use keyboard height for viewport adjustment.
// When hidden, restore normal toolbar height to avoid stale viewport size.
final findInPageHeightPx = findInPageVisible
? (FindInPageWidget.findInPageHeight * pixelRatio).round()
: 0;
final targetHeightPx = event.isVisible && event.heightPx > 0
? event.heightPx + findInPageHeightPx
: toolbarHeightPx;
unawaited(viewportService.setDynamicToolbarMaxHeight(targetHeightPx));
},
);