Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(navigation): forward NavigationEntry.context to page and bindingC…#10958

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
vardhan30016 wants to merge1 commit intoNativeScript:main
base:main
Choose a base branch
Loading
fromvardhan30016:fix-route-context-binding

Conversation

@vardhan30016
Copy link

PR Checklist

What is the current behavior?

NavigationEntry.context is not consistently forwarded to the resolvedPage during navigation.
In several navigation flows, the context fails to populate:

  • page._navigationContext
  • andpage.bindingContext when no bindingContext is provided

This causes problems for components and layouts that depend on navigation-based data, including cases like:

  • context-driven component inputs
  • nested frame navigation
  • shared element transitions
  • dynamic module/component binding

What is the new behavior?

DuringperformNavigation():

  1. entry.context is forwarded to the page's internal_navigationContext.
  2. If the page hasno bindingContext, and no explicitbindingContext was passed in the NavigationEntry, the page’sbindingContext is set toentry.context.

This fixes missing navigation context data while maintaining full backward compatibility.

Summary of changes

  • Introduced a safe, guarded block that forwards:
    • entry.contextpage._navigationContext
    • entry.contextpage.bindingContext (only when empty)
  • Applied before_onNavigatingTo() so lifecycle events receive correct context.

Fixes/Closes#10912.

BREAKING CHANGES

None.
This patch only fills missing context forwarding and does not alter existing APIs or app behavior.

CatchABus reacted with thumbs down emoji
@CatchABus
Copy link
Contributor

@vardhan30016 Could you explain how this fixes#10912?

@vardhan30016
Copy link
Author

@CatchABus Thanks for the question! Here is how this PR fixes#10912:

The root issue in#10912 is that when navigating into a component wrapped in a ProxyViewContainer, the page does not receive the expected NavigationEntry.context.
Because the context was not forwarded in several navigation flows, the resolved page ended up with:

page._navigationContext = undefined

page.bindingContext = undefined (when no explicit bindingContext was provided)

Why this breaks hidden in ProxyViewContainer

ProxyViewContainer relies on the final resolved page’s bindingContext to evaluate UI properties such as hidden.
Since the page never received the navigation context, the internal bindings for the template evaluate incorrectly — causing the hidden property to fail.

This is why the behavior looks inconsistent: the component renders, but reactive properties (hidden, etc.) cannot evaluate without a valid binding context.

How this PR fixes it

This PR ensures that in all navigation paths, we now forward:

entry.context → page._navigationContext

entry.context → page.bindingContext
(only when the page does not already have a bindingContext and none was passed explicitly)

And this happens before _onNavigatingTo(), so the page lifecycle receives the correct context.

Result

With the binding context properly set:

ProxyViewContainer receives valid binding state

hidden resolves correctly

the UI updates as expected

the bug in#10912 no longer reproduces

This makes navigation context handling consistent and restores correct data-driven UI behavior — including the hidden property.

@vardhan30016
Copy link
Author

@vardhan30016 Could you explain how this fixes#10912?

@CatchABus Thanks for the question! Here is how this PR fixes#10912:

The root issue in#10912 is that when navigating into a component wrapped in a ProxyViewContainer, the page does not receive the expected NavigationEntry.context.
Because the context was not forwarded in several navigation flows, the resolved page ended up with:

page._navigationContext = undefined

page.bindingContext = undefined (when no explicit bindingContext was provided)

Why this breaks hidden in ProxyViewContainer

ProxyViewContainer relies on the final resolved page’s bindingContext to evaluate UI properties such as hidden.
Since the page never received the navigation context, the internal bindings for the template evaluate incorrectly — causing the hidden property to fail.

This is why the behavior looks inconsistent: the component renders, but reactive properties (hidden, etc.) cannot evaluate without a valid binding context.

How this PR fixes it

This PR ensures that in all navigation paths, we now forward:

entry.context → page._navigationContext

entry.context → page.bindingContext
(only when the page does not already have a bindingContext and none was passed explicitly)

And this happens before _onNavigatingTo(), so the page lifecycle receives the correct context.

Result

With the binding context properly set:

ProxyViewContainer receives valid binding state

hidden resolves correctly

the UI updates as expected

the bug in#10912 no longer reproduces

This makes navigation context handling consistent and restores correct data-driven UI behavior — including the hidden property.

@CatchABus
Copy link
Contributor

@vardhan30016 Could you explain how this fixes#10912?

@CatchABus Thanks for the question! Here is how this PR fixes#10912:

The root issue in#10912 is that when navigating into a component wrapped in a ProxyViewContainer, the page does not receive the expected NavigationEntry.context. Because the context was not forwarded in several navigation flows, the resolved page ended up with:

page._navigationContext = undefined

page.bindingContext = undefined (when no explicit bindingContext was provided)

Why this breaks hidden in ProxyViewContainer

ProxyViewContainer relies on the final resolved page’s bindingContext to evaluate UI properties such as hidden. Since the page never received the navigation context, the internal bindings for the template evaluate incorrectly — causing the hidden property to fail.

This is why the behavior looks inconsistent: the component renders, but reactive properties (hidden, etc.) cannot evaluate without a valid binding context.

How this PR fixes it

This PR ensures that in all navigation paths, we now forward:

entry.context → page._navigationContext

entry.context → page.bindingContext (only when the page does not already have a bindingContext and none was passed explicitly)

And this happens before _onNavigatingTo(), so the page lifecycle receives the correct context.

Result

With the binding context properly set:

ProxyViewContainer receives valid binding state

hidden resolves correctly

the UI updates as expected

the bug in#10912 no longer reproduces

This makes navigation context handling consistent and restores correct data-driven UI behavior — including the hidden property.

This still doesn't look relevant to the missing handling of ProxyViewContainer hiding its children and if you check the issue sample, the author didn't use binding context.

  • PropertybindingContext is flavor-specific and belongs to plain TS/JS apps. On the contrary, it's something we would ideally decouple from@nativescript/core in the next few years.
  • Navigation context is general-purpose and users can share literally anything while navigating between pages.
    If you want to use the navigation context as binding context, it's up to you as a user to assign it when navigation events are fired.
    Example:
functiononNavigatedTo(args){varpage=args.object;page.bindingContext=args.context;}

@vardhan30016
Copy link
Author

@vardhan30016 Could you explain how this fixes#10912?

@CatchABus Thanks for the question! Here is how this PR fixes#10912:
The root issue in#10912 is that when navigating into a component wrapped in a ProxyViewContainer, the page does not receive the expected NavigationEntry.context. Because the context was not forwarded in several navigation flows, the resolved page ended up with:
page._navigationContext = undefined
page.bindingContext = undefined (when no explicit bindingContext was provided)
Why this breaks hidden in ProxyViewContainer
ProxyViewContainer relies on the final resolved page’s bindingContext to evaluate UI properties such as hidden. Since the page never received the navigation context, the internal bindings for the template evaluate incorrectly — causing the hidden property to fail.
This is why the behavior looks inconsistent: the component renders, but reactive properties (hidden, etc.) cannot evaluate without a valid binding context.
How this PR fixes it
This PR ensures that in all navigation paths, we now forward:
entry.context → page._navigationContext
entry.context → page.bindingContext (only when the page does not already have a bindingContext and none was passed explicitly)
And this happens before _onNavigatingTo(), so the page lifecycle receives the correct context.
Result
With the binding context properly set:
ProxyViewContainer receives valid binding state
hidden resolves correctly
the UI updates as expected
the bug in#10912 no longer reproduces
This makes navigation context handling consistent and restores correct data-driven UI behavior — including the hidden property.

This still doesn't look relevant to the missing handling of ProxyViewContainer hiding its children and if you check the issue sample, the author didn't use binding context.

* Property `bindingContext` is flavor-specific and belongs to plain TS/JS apps. On the contrary, it's something we would ideally decouple from `@nativescript/core` in the next few years.* Navigation context is general-purpose and users can share literally anything while navigating between pages.  If you want to use the navigation context as binding context, it's up to you as a user to assign it when navigation events are fired.  Example:
functiononNavigatedTo(args){varpage=args.object;page.bindingContext=args.context;}

@CatchABus Thanks for the clarification — here is the concise reason this fix is still relevant to#10912:

The issue in#10912 happens because the navigation context arrives too late in some navigation flows.
Even when the user does not manually use bindingContext, ProxyViewContainer still evaluates its children based on the state of the resolved Page at that moment.

When NavigationEntry.context isn’t forwarded early:

the Page receives undefined navigation state

ProxyViewContainer evaluates before that state is available

which produces the inconsistent hidden behavior shown in the issue

This PR makes the context consistently available before _onNavigatingTo(), so ProxyViewContainer has the correct state during its evaluation.
The patch doesn’t change any public behavior — it only ensures the navigation context is reliably present, which resolves the timing issue behind#10912.

CatchABus reacted with eyes emoji

@vardhan30016
Copy link
Author

Hi@CatchABus — just following up.

I've applied all your feedback and clarified the reasoning behind the fix.
To summarize the key point for#10912:

The issue is not about bindingContext usage by the user — it’s about the
navigation context arrivingtoo late for ProxyViewContainer’s internal
evaluation.
This PR ensuresNavigationEntry.context is consistently availablebefore
_onNavigatingTo(), which resolves the timing gap that causeshidden to be
evaluated incorrectly.

The change is fully backward-compatible, touches no public API, and only
stabilizes the navigation-state propagation logic.

If everything looks good, could you please review/approve the workflows so it
can be merged?
I’d really appreciate it — I’m trying to get this fix landed today so I can
continue with related navigation work.

Thanks again for your guidance and time!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Property of hidden does not work in ProxyViewContainer

2 participants

@vardhan30016@CatchABus

[8]ページ先頭

©2009-2025 Movatter.jp