-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Issue Description
Bug: androidOverflowInset applies padding even when insets are marked as consumed
When using androidOverflowEdge="dont-apply" and listening to the androidOverflowInset event, NativeScript automatically applies padding even when insets are marked as consumed. This is a runtime issue.
Expected behavior:
When inset.topConsumed = true (and similar for other edges) is set in the androidOverflowInset event handler, NativeScript should not apply padding, regardless of the original inset values.
Actual behavior:
NativeScript applies padding based on whether the original inset values were 0 (leftPreviouslyConsumed), not based on whether the insets are marked as consumed (leftConsumed). This happens in LayoutBase.java line 280:
base.setPadding(leftPreviouslyConsumed ? 0 : leftInset, topPreviouslyConsumed ? 0 : topInset, rightPreviouslyConsumed ? 0 : rightInset, bottomPreviouslyConsumed ? 0 : bottomInset);The code checks leftPreviouslyConsumed (whether the original value was 0) instead of leftConsumed (whether it was marked as consumed by the event handler).
Workaround:
The current workaround is to set inset values to 0 AND mark them as consumed:
inset.top = 0;
inset.bottom = 0;
inset.left = 0;
inset.right = 0;
inset.topConsumed = true;
inset.bottomConsumed = true;
inset.leftConsumed = true;
inset.rightConsumed = true;This is counterintuitive because marking as consumed should be sufficient.
Proposed fix:
In LayoutBase.java line 280, the code should check leftConsumed instead of (or in addition to) leftPreviouslyConsumed:
// Current (buggy):
base.setPadding(leftPreviouslyConsumed ? 0 : leftInset, ...);
// Should be:
base.setPadding((leftPreviouslyConsumed || leftConsumed) ? 0 : leftInset, ...);Related file:
packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/LayoutBase.java(line 280)
Reproduction
- Create a Frame with
androidOverflowEdge="dont-apply":
<Frame id="rootFrame" androidOverflowEdge="dont-apply" loaded="onLoaded" />- Listen to the
androidOverflowInsetevent and mark insets as consumed without setting their values to 0:
export function onLoaded(args: EventData) {
const rootFrame = args.object as Frame;
rootFrame.on("androidOverflowInset", (event: any) => {
const { inset } = event;
// Store values for CSS variables
const values = {
top: inset.top,
bottom: inset.bottom,
left: inset.left,
right: inset.right
};
// Mark as consumed (this should prevent padding, but doesn't)
inset.topConsumed = true;
inset.bottomConsumed = true;
inset.leftConsumed = true;
inset.rightConsumed = true;
});
}- Run the app on an Android device/emulator
- Observe that padding is still applied automatically, even though insets are marked as consumed
Expected: No padding should be applied when insets are marked as consumed.
Actual: Padding is applied based on the original inset values.
Relevant log output (if applicable)
No error messages, but the behavior can be observed visually as unwanted padding is applied to the view.Environment
OS: Linux 6.17 Fedora Linux 43 (Workstation Edition)
CPU: (20) x64 Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
Shell: /usr/bin/zsh
node: 22.14.0
npm: 10.9.2
nativescript: 9.0.1
# android
java: 17.0.16
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found
# ios
xcode: Not Found
cocoapods: Not Found
python: 3.14.2
python3: 3.14.2
ruby: 3.4.7
platforms: Not FoundDependencies
"dependencies": {
"@learn6502/6502": "workspace:^",
"@learn6502/common-ui": "workspace:^",
"@nativescript/core": "~9.0.10",
"@nativescript/localize": "^5.2.0",
"@nativescript/tailwind": "^4.0.7",
"tailwindcss": "^4.1.18"
},
"devDependencies": {
"@nativescript/android": "9.0.1",
"@nativescript/types": "~9.0.0",
"@nativescript/webpack": "^5.0.29",
"@tailwindcss/postcss": "^4.1.18",
"autoprefixer": "^10.4.23",
"nativescript": "^9.0.1",
"postcss": "^8.5.6",
"postcss-cli": "^11.0.1",
"postcss-discard-empty": "^7.0.1",
"postcss-import": "^16.1.1",
"postcss-nested": "^7.0.2",
"string-replace-loader": "^3.3.0",
"typescript": "^5.9.3"
}Please accept these terms
- I have searched the existing issues as well as StackOverflow and this has not been posted before
- This is a bug report
- I agree to follow this project's Code of Conduct