Skip to content

Determine what should happen when reloading after a shallow navigation #16480

Description

@Rich-Harris

Describe the problem

Opening this to keep track of #16449 (comment), in case we don't figure out an answer we like before that PR gets merged.

If you shallowly navigate from /photos to /photos/123 (displaying a modal), then reload such that you're then on the 'real' photo page, then navigate back, then navigate forwards, you will see the modal again. This feels a bit unnatural to me.

Describe the proposed solution

Reloading should probably 'upgrade' the history entry such that a back-then-forward navigation takes you to the full /photos/123 page rather than /photos with a modal.

Things I'm not sure about:

  • whether this should be configurable
  • whether it's somehow related to persistState
  • whether any other entries in the stack should also be upgraded, so that lateral navigations are consistent

(I did a very brief survey of whatever prior art I could find and didn't turn up much. Our go-to Instagram example fails hard at this test. Might be worth looking at https://nextjs.org/docs/app/api-reference/file-conventions/intercepting-routes, though the docs themselves are rather vague, and the feature seems a bit complicated to use.)

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionNot sure if we want to do this yet, also design work needed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions