Repository navigation
Ignore the launching Intent's deep link when setting the graph - #224
Merged
Merged
Conversation
Setting a NavController graph makes the Navigation library navigate to the launching Intent's deep link: the destination and arguments in its deep-link extras, or the destination whose deep link matches its data. Hotwire navigates from the configuration's start location and its own visits, so NavigatorHost now sets the graph while the Activity holds an empty Intent, then gives the Activity its launching Intent back unchanged. This replaces ensureDeeplinkStartLocationValid(), which rewrote parts of the launching Intent's extras and isn't needed anymore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Setting the graph creates the start fragment and calls destination listeners right away, so app code saw an empty Intent in that moment. The Activity now holds a copy of its launching Intent without the data and the deep-link extras, so the action and the app's own extras stay visible. If the extras can't be read, it falls back to an empty Intent. NavHostFragment.onCreate() sets a graph supplied through its arguments or XML, so the same copy is in place while it runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A graph supplied through NavHostFragment's arguments or XML can match a deep link by the Intent's action alone, so the copy that keeps the action isn't enough there. super.onCreate() now runs while the Activity holds an empty Intent. Hotwire's own graph only has deep links by uri, so its setup keeps the copy with the action and the app's extras. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Setting a
NavControllergraph makes the Navigation library navigate to the launching Intent's deep link: the destination and arguments in its deep-link extras, or the destination whose deep link matches its data. Hotwire picks its start destination from the configuration's start location and navigates through its own visits, so it never needs that.NavigatorHostnow sets a graph only while the Activity holds a copy of its launching Intent without the data and the deep-link extras, then gives the Activity its launching Intent back unchanged.NavHostFragment.onCreate(), which sets a graph supplied through arguments or XML, the Activity holds an empty Intent, since that graph can match a deep link by action alone.FragmentFactoryor a destination listener, still sees the Intent's action and the app's own extras.This replaces
ensureDeeplinkStartLocationValid(), which rewrote parts of the launching Intent's extras. That function was public for tests, so a subclass that called it needs to drop the call.The tests launch a real
NavigatorHostwith deep-link data or deep-link extras and check that only the start destination opens, that the Activity's Intent is unchanged, and what app code sees while the graph is set. The navigation tests fail onmain, where the launching Intent opens the bottom sheet destination.🤖 Generated with Claude Code