Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Adding and removing tabs causing badges to shift tab #70

Open
gregersen79 opened this issue Jun 4, 2019 · 3 comments
Open
Labels
bug pr welcome A pull request adressing the issue is welcome
Milestone

Comments

@gregersen79
Copy link

On Android, when removing or adding a tab, the badges are on the wrong tabs.
It seems it is only with bottom tab placement.
I have recreated this issue with the sample app on Samsung Galaxy S8 running Android 8.0.0:

  • Select "Use bottom tab placement"
  • Press ex. "Tabbed page root with children as navigation pages".
  • Press "Remove tab".

Before pressing remove tab:
Screenshot_20190604-103529

After pressing remove tab:
Screenshot_20190604-104548

Pressing "Add tab" instead of "Remove tab":
Screenshot_20190604-103539

@xabre xabre added the bug label Jul 7, 2019
@Adam--
Copy link

Adam-- commented Oct 3, 2019

I'm experiencing a similar behavior with top tabs on android using the BadgedTabbedPageRenderer.

I think this issue is best described as the badges staying on the original tab index after tab pages are add/removed at runtime.

Setting up a simple example where tabs can be added and removed at either the left or right at runtime reproduces this issue.

Adding tabs to the left
Before add

Add 2 tabs to the left:
After add

Observed behavior
The badges were on page 1, 2, and 4 (tab indices 0, 1, and 3) before adding new pages, but after adding pages the badges are on page L2, L1, and 2 (tab indices 0, 1, and 3).

Expected behavior
The badges are on page 1, 2, and 4 (new tab indices 2, 3, and 5)

Removing and adding tabs to the right
Before remove right

Remove 2 tabs on the right:
After remove right 2

Add 1 tab on the right:
After add right

Observed behavior
The badges were on pages 1, 2, and 4 (tab indices 0, 1, and 3) before removing pages and adding new pages, but after they were on pages 1, 2, and R1 (tab indices 0, 1, and 3)

Expected behavior
The badges are on page 1 and 2 (page 4 was removed)

@Adam--
Copy link

Adam-- commented Oct 3, 2019

I'd like to help with fixing this bug, but I'm struggling a bit. It seems we should try to "refresh" all of the tab view's badge views. To do this I've tried a few approaches, most notable are the following.

Iterating over the BadgeViews collection and calling UpdateFromElement on the view using the page whenever tabs are added or removed (OnTabAdded, OnTabRemoved), but it doesn't seem to do anything.

            foreach (var (element, badgeView) in BadgeViews)
            {
                badgeView.UpdateFromElement((Page)element);
            }

Calling AddTabBadge for all of the pages. AddTabBadge refreshes the badge if one already exists and creates a new one if it doesn't. This fixed the "Adding tabs to the left" case above, but not the "Removing and adding tabs to the right" case.

            for (var i = 0; i < Element.Children.Count; i++)
            {
                AddTabBadge(i);
            }

These attempts did not seem to affect the bottom tab behavior.

Any thoughts on this issue?

@Adam--
Copy link

Adam-- commented Oct 3, 2019

Was there a version where this had previously worked? It's shown as supported in the readme.

@xabre xabre added this to the 2.3.0 milestone Mar 7, 2020
@xabre xabre added the pr welcome A pull request adressing the issue is welcome label Mar 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug pr welcome A pull request adressing the issue is welcome
Projects
None yet
Development

No branches or pull requests

3 participants