Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.7k
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…ontext when none provided (closesNativeScript#10912)
CatchABus commentedNov 24, 2025
@vardhan30016 Could you explain how this fixes#10912? |
vardhan30016 commentedNov 24, 2025
@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. 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. 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 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 commentedNov 24, 2025
@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. 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. 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 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 commentedNov 24, 2025
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.
functiononNavigatedTo(args){varpage=args.object;page.bindingContext=args.context;} |
vardhan30016 commentedNov 24, 2025
@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. 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. |
vardhan30016 commentedNov 25, 2025
Hi@CatchABus — just following up. I've applied all your feedback and clarified the reasoning behind the fix. The issue is not about bindingContext usage by the user — it’s about the The change is fully backward-compatible, touches no public API, and only If everything looks good, could you please review/approve the workflows so it Thanks again for your guidance and time! |
PR Checklist
What is the current behavior?
NavigationEntry.contextis not consistently forwarded to the resolvedPageduring navigation.In several navigation flows, the context fails to populate:
page._navigationContextpage.bindingContextwhen no bindingContext is providedThis causes problems for components and layouts that depend on navigation-based data, including cases like:
What is the new behavior?
During
performNavigation():entry.contextis forwarded to the page's internal_navigationContext.bindingContextwas passed in the NavigationEntry, the page’sbindingContextis set toentry.context.This fixes missing navigation context data while maintaining full backward compatibility.
Summary of changes
entry.context→page._navigationContextentry.context→page.bindingContext(only when empty)_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.