Repository navigation
fix(android): reset background color when it becomes transparent or is removed - #9
Merged
Merged
Conversation
…s removed When a view can use the outline provider (no border width, image, clip-path or box shadow, e.g. a label with only a border-radius), `_applyBackground` only applied the color when its native value was truthy. `transparent` is 0 and a removed color is undefined, so the previously set ColorDrawable was kept: toggling a class that sets a background-color left the old color on screen. Apply any defined color (including transparent) and restore the default background (or clear the drawable fill) when the color is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Android, when a view can use the outline provider (no border width, image, clip-path or box shadow — e.g. a label with only a
border-radius),_applyBackgroundonly applied the background color if its native value was truthy:transparentis native int0, sosetBackgroundColorwas skipped and the previousColorDrawablestayed.undefined, and theCLEAR_BACKGROUND_COLORhandling only existed in theBorderDrawablebranch, so nothing was reset either.Seen in oss-weather on Android 16: a segmented control of labels toggling
modernSegment/modernSegmentSelectedclasses kept the selected tile background after the selection moved. Views without a border-radius also take this path, so they were affected as well.Fix
transparent.needsNativeDrawableFill, e.g. Button / ActionBar).Verification
Scratch app on an API 36 emulator using published
@akylas/nativescript9.0.23, labels withborder-radius: 8and a background from a CSS variable, toggling classes:background-color: transparentColorDrawable(ffff0000)ColorDrawable(0)ColorDrawable(ffff0000)null(default)Added two on-device tests in
apps/automated/src/ui/view/view-tests.android.ts(transparent then unset on a label with border-radius; class toggle with a CSS-variable background). The automated suite was not run locally.🤖 Generated with Claude Code