Skip to content

ModalDialogService view bindings don't fire if AppComponent has changeDetection of OnPush #1217

Open
@vultix

Description

@vultix

Bug Description

I have a modal view that I am opening using the ModalDialogService. Almost none of the views labels, image, or buttons were behaving as expectedly. After spending hours to track down the issue here is what I found:

If the root AppComponent has changeDetection: ChangeDetectionStrategy.OnPush set, no bindings will be properly set in any modal dialog in the app.

This includes binding button text, label text, Image source.
This does not seem to prevent events from firing.

Reproducing

I have created a nativescript playground app that shows the issue:
https://play.nativescript.org/?template=play-ng&id=rxarWp&v=3

If you tap 'Open Modal' the modal should have a Button and 3 Labels, however two of those labels don't show up because their text was set using a binding.

To fix those bindings all you need to do is comment out the line
changeDetection: ChangeDetectionStrategy.OnPush
from app.component.ts.

Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions