Conversation
…ontext when none provided (closes NativeScript#10912)
…ar overlaying status bar (closes NativeScript#10856)
|
@vardhan30016 Could you explain how this fixes #10856; |
@CatchABus Thanks for the question! Here is how this PR fixes #10856: The root issue in #10856 appears visually as “data not passed through route”, but the real underlying problem is that the ActionBar was being positioned underneath the Android system status bar on newer Android versions (API 29+, especially Android 13–16 with edge-to-edge mode enabled). Because the ActionBar overlapped with the status bar, the system insets were not applied correctly, causing several side-effects—including cases where ActionBar-attached components (such as routed components using withComponentInputBinding()) appeared to have missing or non-applied data during initial render. Why this happens On modern Android versions: Toolbar no longer automatically applies top inset padding. NativeScript’s ActionBar uses a Toolbar. Without padding, the ActionBar is drawn under the status bar. This breaks layout measurement and affects the initial binding cycle for routed components. In short: when the ActionBar layout is wrong, component inputs from routing can appear missing or not applied. How this PR fixes it This PR ensures correct inset handling on Android 10+: Enables setFitsSystemWindows(true) on the Toolbar. Adds an OnApplyWindowInsetsListener to read system bar insets. Applies the top inset as padding to the ActionBar’s native view. Wraps logic in try/catch for backward compatibility. Result Once the correct insets are applied: The ActionBar renders below the status bar. Routed components receive proper layout and binding timing. withComponentInputBinding() gets the correct input props on first render. The issue described in #10856 no longer occurs. This patch doesn’t change any public API—it simply restores correct layout behavior under the newer Android edge-to-edge system. |
PR Checklist
What is the current behavior?
On newer Android versions (API 29+), especially Android 14–16 (edge-to-edge navigation),
the
ActionBaris rendered under the status bar.This causes the ActionBar title, menu items, and navigation button to overlap with the system status bar.
This is due to
Toolbarnot applyingWindowInsetstop padding on newer Android layouts.Related issue: #10856
What is the new behavior?
During
createNativeView()on Android:setFitsSystemWindows(true)for correct inset handling.OnApplyWindowInsetsListeneris attached to read the top system inset.This ensures the ActionBar is correctly positioned below the status bar on all Android versions.
Fixes #10856.
BREAKING CHANGES
None.
This patch does not modify public APIs or change behavior for older Android versions.
It only resolves layout misalignment under edge-to-edge mode on Android 10+.