Skip to content

When using router.replace() from next/navigation for routing, the modal opened with the next.js slot does not close. #71795

Open
@2dubbing

Description

@2dubbing

Link to the code that reproduces this issue

https://github.com/2dubbing/nextgram

To Reproduce

  1. npm install
  2. npm run dev
  3. Open web browser http://localhost:3000
  4. Click the square UI with the number on it on the screen.
  5. Click the X button in the modal window.

Current vs. Expected behavior

Current: �If you route with router.replace() while the modal window is open, the modal window will not close.

Expected behavior: Routing with router.replace() should close any open modal windows.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Mon Aug 12 20:51:54 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 20.18.0
  npm: 10.8.2
  Yarn: N/A
  pnpm: 9.6.0
Relevant Packages:
  next: 15.0.0-canary.61
  react: 19.0.0-rc.0
  react-dom: 19.0.0-rc.0
  typescript: 5.5.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

create-next-app

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

You might want to use router.replace for the following reasons
Because we think it's better for usability to use router.replace rather than router.back if the data change is successful on the Change Form Data page.

thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.create-next-appRelated to our CLI tool for quickly starting a new Next.js application.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions