Skip to content

ActionItems are displayed in the wrong order using *ngIf #689

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

Closed
m-abs opened this issue Mar 3, 2017 · 1 comment · Fixed by #979
Closed

ActionItems are displayed in the wrong order using *ngIf #689

m-abs opened this issue Mar 3, 2017 · 1 comment · Fixed by #979
Assignees
Milestone

Comments

@m-abs
Copy link
Contributor

m-abs commented Mar 3, 2017

If you have an ActionBar with optional ActionItems, the items switches place when the *ngIf state changes.

You can see what I mean in this gif:
peek 2017-03-03 13-53

There are two ActionItem, one with the title=1 and one with the title=2.

  1. tap hides ActionItem 1.
  2. tap shows ActionItem 1 again, but now on the right side of ActionItem 2
  3. tap hides ActionItem 2
  4. tap shows ActionItem 2 again, now in the proper order
  5. tap hides both
  6. tap shows both in the proper order.

I would expect the items to be shown in the order they're in the template:

<ActionBar>
  <ActionItem text="1" *ngIf="show1"></ActionItem>
  <ActionItem text="2" *ngIf="show2"></ActionItem>
</ActionBar>

I have a demo project here:
https://github.com/m-abs/tns-webpack-ng2.3/tree/action-ngIf-order

@m-abs m-abs changed the title ActionItems are displayed on the wrong order using *ngIf ActionItems are displayed in the wrong order using *ngIf Mar 3, 2017
@tsonevn tsonevn added the bug label Mar 17, 2017
@tsonevn
Copy link
Contributor

tsonevn commented Mar 17, 2017

Hi @m-abs,
Thank you for reporting this issue,
I tested sample project and was able to reproduce this behavior.
As a temporary solution, you could use visibility property to hide the component, which will keep the elements in the same order. For example:

<ActionBar>
  <ActionItem text="1"  [visibility]="show1 ? 'visible' : 'collapsed'"></ActionItem>
  <ActionItem text="2"  [visibility]="show2 ? 'visible' : 'collapsed'"></ActionItem>
</ActionBar>

@sis0k0 sis0k0 added this to the 3.1 TBD milestone May 5, 2017
@vakrilov vakrilov modified the milestones: 3.2 TBD, 3.1 Jul 5, 2017
@vakrilov vakrilov modified the milestones: 4.x (TBD), 4.3 Aug 21, 2017
@sis0k0 sis0k0 modified the milestones: 4.3, 4.x (TBD) Sep 4, 2017
@sis0k0 sis0k0 added in progress and removed backlog labels Sep 4, 2017
sis0k0 added a commit that referenced this issue Sep 4, 2017
ActionBar's insertChild method is now passed a `next` view argument. When the view to insert is an ActionItem, `next` is used to find the correct position to insert the new item.

fixes #689
@ghost ghost assigned sis0k0 Sep 4, 2017
@sis0k0 sis0k0 added the renderer label Sep 7, 2017
sis0k0 added a commit that referenced this issue Sep 7, 2017
ActionBar's insertChild method is now passed a `next` view argument. When the view to insert is an ActionItem, `next` is used to find the correct position to insert the new item.

fixes #689
sis0k0 added a commit that referenced this issue Sep 7, 2017
refactor(renderer): invoke removeFromQueue for every element

refactor(action-bar): insert ActionItems at correct positions
ActionBar's insertChild method is now passed a next view argument. When the view to insert is an ActionItem, next is used to find the correct position to insert the new item.

refactor(renderer): patch every View with ViewExtensions
When a View is passed through the renderer on insert/remove it's patched
with ViewExtensions for its class. That is done for parent views and for
child views.

fixes #689, fixes #978
@ghost ghost removed the in progress label Sep 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants