Skip to content

fix(android): guard TextBase fontSize reset values#11222

Open
ebsi-bblake wants to merge 1 commit into
NativeScript:mainfrom
ebsi-bblake:fix/android-textbase-fontsize-null
Open

fix(android): guard TextBase fontSize reset values#11222
ebsi-bblake wants to merge 1 commit into
NativeScript:mainfrom
ebsi-bblake:fix/android-textbase-fontsize-null

Conversation

@ebsi-bblake
Copy link
Copy Markdown

Fixes #11221.

Summary

  • Add a null guard to Android TextBase font-size native setter so style resets do not crash when fontSize resolves to null or undefined.
  • Preserve existing behavior for numeric font sizes and { nativeSize } default values.
  • Leave Android font scaling behavior unchanged.

Reproduction

Using nativescript-vue, toggling an inline font-size style off can reset the previous style value to null:

<script setup lang=\"ts\">
import { ref } from 'nativescript-vue'

const enabled = ref(true)
</script>

<template>
  <Button
    text=\"Toggle\"
    @tap=\"enabled = !enabled\"
  />

  <Label
    text=\"Font size repro\"
    :style=\"enabled ? { fontSize: 20 } : {}\"
  />
</template>

On Android, that reset can reach TextBase and throw:

TypeError: Cannot read properties of null (reading 'nativeSize')

Testing

  • Verified the patch in an app-level NativeScript Vue repro where the crash occurred before the guard.
  • Ran git diff --check locally.

No full NativeScript test suite was run locally because this clone did not have repo dependencies installed.

@NathanWalker
Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9784ebb0-9d4a-4fae-9f63-aa7929ebe3d5

📥 Commits

Reviewing files that changed from the base of the PR and between 69dc869 and 5185c78.

📒 Files selected for processing (1)
  • packages/core/ui/text-base/index.android.ts

Walkthrough

The Android TextBase font size setter now handles null and undefined values by returning early, preventing crashes when inline styles are reset and fontSize is cleared during component updates.

Changes

TextBase Android font size null-safety

Layer / File(s) Summary
Android font size setter null-safety guard
packages/core/ui/text-base/index.android.ts
The fontSizeProperty.setNative handler accepts null or undefined and returns early, avoiding attempts to access nativeSize property on null values that would cause runtime crashes during style resets.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A null crept in one fateful day,
The setter tried to read its way,
But now we guard with grace and care,
An early return stops the despair,
Android TextBase flies, free as a hare! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and specifically summarizes the main change: adding a null guard to Android TextBase fontSize handler to prevent crashes during style resets.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the null safety fix, its purpose, reproduction case, and testing approach.
Linked Issues check ✅ Passed The pull request fully addresses issue #11221 by adding a null guard to prevent crashes when fontSize is reset to null/undefined while preserving existing behavior for numeric sizes.
Out of Scope Changes check ✅ Passed All changes are scoped to the Android TextBase fontSize setter null-safety fix; no unrelated modifications are present in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android TextBase fontSize setter crashes when style reset passes null

2 participants