Skip to content

Commit 2beae5b

Browse files
bundyomanoldonev
authored andcommitted
fix(css-android): restore elements' native features if offending css is removed while the app is running (#7789)
1 parent f82cf08 commit 2beae5b

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎tns-core-modules/ui/styling/background.android.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export module ad {
4040
}
4141

4242
const background = view.style.backgroundInternal;
43-
const drawable = nativeView.getBackground();
43+
let drawable = nativeView.getBackground();
4444
const androidView = <any>view as AndroidView;
4545
// use undefined as not set. getBackground will never return undefined only Drawable or null;
4646
if (androidView._cachedDrawable === undefined && drawable) {
@@ -50,12 +50,21 @@ export module ad {
5050

5151
if (isSetColorFilterOnlyWidget(nativeView)
5252
&& drawable
53-
&& !(drawable instanceof org.nativescript.widgets.BorderDrawable)
5453
&& !background.hasBorderWidth()
5554
&& !background.hasBorderRadius()
5655
&& !background.clipPath
5756
&& !background.image
5857
&& background.color) {
58+
59+
if (drawable instanceof org.nativescript.widgets.BorderDrawable) {
60+
if (!(androidView._cachedDrawable instanceof android.graphics.drawable.Drawable.ConstantState)) {
61+
return;
62+
}
63+
64+
drawable = androidView._cachedDrawable.newDrawable(nativeView.getResources());
65+
nativeView.setBackground(drawable);
66+
}
67+
5968
const backgroundColor = (<any>drawable).backgroundColor = background.color.android;
6069
drawable.mutate();
6170
drawable.setColorFilter(backgroundColor, android.graphics.PorterDuff.Mode.SRC_IN);

0 commit comments

Comments
 (0)