-
-
Notifications
You must be signed in to change notification settings - Fork 241
ActionItem with *ngIf throws an error when it's removed #942
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
Comments
@madakk I have created this test application where an ActionItem is removed/added using *ngIf structural directive. It works as expected on both iOS and Android. In order to investigate your specific case please provid3e more information and sample code base that can reproduce the issue you are struggling with. |
I'm sorry, I failed to notice this in my original report, this only happens when the ActionItem is provided inside an Simply change the Edit: Further investigation shows that the difference is that ActionBar preempts the view removal with its meta, calling removeItem instead, whereas ActionBarExtension handles the removal after it's already been removed from view, in its onActionDestroy handler. |
I think I just ran into the same issue without I don't have a demo project to reproduce it, but our template looks like this: <ActionBar>
<ActionItem
*ngIf="(tabs.activeComponent | async) == 'bookshelf'"
(tap)="toSettings()"
icon="res://settings"
ios.position="right"
[text]="'SETTINGS' | translate"></ActionItem>
</ActionBar> |
From @madakk on August 13, 2017 10:54
Looks like this is happening because ActionItems.removeItems calls _removeView directly: https://github.com/NativeScript/NativeScript/blob/12020bd8bbdb8d87f9100d713590d0db982b7661/tns-core-modules/ui/action-bar/action-bar-common.ts#L190
But the nativescript angular handler has already removed the view (due to the same *ngIf directive) causing the error.
I believe this can be fixed by simply checking that the item's parent is actually the actionBar before attempting to remove it.
Copied from original issue: NativeScript/NativeScript#4691
The text was updated successfully, but these errors were encountered: