NativeScript icon indicating copy to clipboard operation
NativeScript copied to clipboard

Android: ActionBar wrong background-color after back-navigation since 7.2.0

Open felixkrautschuk opened this issue 3 years ago • 26 comments

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 7.2.0
  • Cross-platform modules: 7.3.0
  • Android Runtime: 7.0.1
  • iOS Runtime: -
  • XCode Version: -
  • Plugin(s): -

Describe the bug When navigating from page A to page B and page B has an ActionBar with a different background-color than page A and the user navigates back from page A, the ActionBar of page A has now the background-color of page B until you navigate forwards to page A.

  • This is NOT happening on iOS
  • This was not happening with @nativescript/core 7.1.4 -> issue exists since 7.2.0, probably caused by https://github.com/NativeScript/NativeScript/pull/9120

Not sure if it is related only to the ActionBar, but it is the only thing I noticed from our real app at least, the other widgets seem not to be affected.

<!-- page A -->
<Page>
    <ActionBar title="Main page" backgroundColor="CadetBlue" color="white"/>
</Page>
<!-- page B -->
<Page backgroundColor="black">
    <ActionBar title="Detail page" backgroundColor="black" color="white"/>
</Page>

ns-bg

To Reproduce follow the steps from the GIF with the sample app provided below

Expected behavior When navigating back to page A, the ActionBar should have the background-color defined in xml or css, not the background-color from the page B.

Sample project NSAndroidBackgroundColorIssue.zip

Additional context none

felixkrautschuk avatar Mar 12 '21 11:03 felixkrautschuk

I think I am responsible for this. will fix this.

farfromrefug avatar Mar 12 '21 12:03 farfromrefug

@farfromrefug thanks for looking into this.

jwrascoe avatar Mar 12 '21 15:03 jwrascoe

@jwrascoe @felixkrautschuk actually this one https://github.com/NativeScript/NativeScript/pull/9223 fixes it. @rigor789 can you look at it?

farfromrefug avatar Mar 12 '21 20:03 farfromrefug

I'm having the same issue although with different symptoms in NS Angular. In my case it is forward navigation to a page with nested router outlets and the action bar changes to the default white color. If I remove the nested router outlets the problem goes away. I've reverted to "@nativescript/core": "7.1.4" to temporarily fix the issue.

rbudnar avatar Mar 30 '21 12:03 rbudnar

@rbudnar its broken in @nativescript/core@latest because this PR has not been released yet.

https://github.com/NativeScript/NativeScript/pull/9223

I have worked around it by forking and applying the PR till it makes it into the main repo.

Not sure when it will be released so I'm using this method till it does.

jwrascoe avatar Mar 30 '21 12:03 jwrascoe

@jwrascoe Thanks! I just wanted to point out the additional symptomatology in case anyone else is experiencing what I am since it is different from the one initially listed in the issue.

rbudnar avatar Mar 30 '21 13:03 rbudnar

Thanks @rbudnar. Reverting has done the trick while waiting on the PR.

jamescodesthings avatar Mar 30 '21 16:03 jamescodesthings

PR flagged for 8.1 - curious if a 7.x patch of it would be worth it?

NathanWalker avatar Apr 02 '21 23:04 NathanWalker

@NathanWalker it would be handy to have until we all transition to NS8. I started looking at that today... bumped into the enum switch to coretypes (I’m an xplat shop) not sure what else may pop up

jwrascoe avatar Apr 03 '21 00:04 jwrascoe

Either is fine with me. I'd love to just update to 8.x but I can see how the major version bump might not work out for everyone just yet.

rbudnar avatar Apr 03 '21 00:04 rbudnar

@NathanWalker 👍

jwrascoe avatar Apr 03 '21 00:04 jwrascoe

Any movement on this issue? It looks like the PR may not yet have been merged. It's the thing holding us back from Updating to 8.

jamescodesthings avatar Jun 21 '21 11:06 jamescodesthings

Is there a bit of progress here? After a long migration to {N}8 this is a blocker to get the new version out to the play store.

teha-at avatar Aug 17 '21 20:08 teha-at

@teha-at could you test the 8.1.0 alpha version? (Look on npm) might be fixed there

farfromrefug avatar Aug 17 '21 20:08 farfromrefug

@teha-at could you test the 8.1.0 alpha version? (Look on npm) might be fixed there

sorry, looks like in 8.1.0-alpha.1 the problem are still there.

My test procedure was:

ns create testBackground --ng
  • Change the @nativescript/core version to ^8.1.0-alpha.1 in package.json
  • Replace the ListView because of another error there with a simple button with [nsRouterLink]="['/item', 1]"

Set the background color for the action bars

<ActionBar title="My App" backgroundColor="#2fffca"> </ActionBar>

and

<ActionBar title="Details" backgroundColor="#fdff33"></ActionBar>

Start the app with

ns clean
ns run android --emulator

After a click on the button the detail view with a yellow action bar appears but if i go back the background color is still yellow.

The same code with iOS has no problems, the background color change every time as expected.

teha-at avatar Aug 18 '21 07:08 teha-at

@teha-at we have the fix. we need to merge and release (will be 8.1.0 which is alpha stage)

farfromrefug avatar Aug 20 '21 12:08 farfromrefug

@farfromrefug I tried it again with 8.1.1 and the error are still there. Do you have any ideas why the fix #9223 don't work?

teha-at avatar Sep 13 '21 10:09 teha-at

@teha-at hmm I'm not sure if we ended up merging #9223 - the reason it was (auto) closed is because the target branch has been deleted.

rigor789 avatar Sep 13 '21 11:09 rigor789

@rigor789 oh thats annoying. What can we do to make sure it's in the next version?

teha-at avatar Sep 14 '21 08:09 teha-at

Confirmed the code isn't in the master branch:

git --no-pager grep '_applyBackground'

gives no results.

Can the PR be reopened and targeted at the next branch?

jamescodesthings avatar Sep 16 '21 07:09 jamescodesthings

@rigor789 @jamescodesthings @teha-at i opened a PR on master https://github.com/NativeScript/NativeScript/pull/9548

farfromrefug avatar Sep 16 '21 08:09 farfromrefug

Now here, to save me having to look again: https://github.com/NativeScript/NativeScript/tree/feat/refactored-background-handling

jamescodesthings avatar Oct 14 '21 14:10 jamescodesthings

Any updates on this?

OPADA-Eng avatar Oct 17 '21 06:10 OPADA-Eng

@rigor789 t he PR has been released, right ?

farfromrefug avatar Oct 17 '21 06:10 farfromrefug

@farfromrefug not yet, I don't think - I did a cleanup pass recently and did some testing to make sure it's all good, and just need to wrap that up.

rigor789 avatar Oct 17 '21 13:10 rigor789

Just a heads up that I think this issue can be closed now. It appears the fix is in 8.2.1: https://github.com/NativeScript/NativeScript/blob/8.2.1-core/packages/core/ui/action-bar/index.android.ts#L224

Thanks for everyone's hard work.

jamescodesthings avatar Mar 28 '22 08:03 jamescodesthings

I'm using version "@nativescript/core": "~8.5.0" and also experiencing the same issue - but on <Button> background color

<Button backgroundColor="green"></Button>

(1) Home page -> Clicking on element A -> switching to "details page" -> Clicking the phone's Back button: the buttons background becomes "white" ( font color stay correct )

From that point ^^ - (2) Home page -> Clicking on element A (again) -> switching to the same "details page" -> Clicking on a button with the following code:

goHome() {    
      this.routerExtensions.navigate(['/'], {
          transition: {
              name: "fade"
          }
      });
  }

Suddenly bring the background back

arLevi avatar Jun 20 '23 06:06 arLevi