nextui icon indicating copy to clipboard operation
nextui copied to clipboard

[BUG] - Select becomes unusable after Next.js App Router client-side navigation

Open PiotrZacharskiThey opened this issue 4 months ago • 2 comments

HeroUI Version

3.1.0

Describe the bug

Select becomes unusable after Next.js App Router client-side navigation

The HeroUI Select component becomes unusable after navigating away from a page and returning using Next.js App Router client-side navigation.

The issue occurs with a controlled Select component. After returning to the page:

  • the value prop is still correct,
  • the component renders normally,
  • but the selected value is not displayed,
  • the Select trigger stops responding,
  • the dropdown cannot be opened.

Forcing the component to remount fixes the issue, which suggests that some internal state of the Select component is not restored correctly after navigation.

Environment

Versions

{
  "@heroui/react": "3.1.0",
  "@heroui/styles": "3.1.0",
  "next": "16.2.7",
  "react": "19.2.3",
  "react-dom": "19.2.3"
  "@react-aria/interactions": "^3.28.0"
}

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Create a controlled HeroUI Select:
'use client';

import { useState } from 'react';
import { Select, ListBox } from '@heroui/react';

export default function Example() {
  const [value, setValue] = useState('all');

  return (
    <Select
      value={value}
      onChange={(newValue) => setValue(newValue as string)}
    >
      <Select.Trigger>
        <Select.Value />
      </Select.Trigger>

      <Select.Popover>
        <ListBox>
          <ListBox.Item id="all" textValue="All">
            All
          </ListBox.Item>

          <ListBox.Item id="active" textValue="Active">
            Active
          </ListBox.Item>
        </ListBox>
      </Select.Popover>
    </Select>
  );
}
  1. Navigate to another route using Next.js client-side navigation:
<Link href="/another-page">
  Open another page
</Link>
  1. Navigate back to the original page using another Next.js Link:
<Link href="/original-page">
  Go back
</Link>
  1. Try interacting with the Select.

Expected behavior

After returning to the page:

  • Select displays the current value.
  • Select opens normally.
  • User can change the selection.

Actual behavior

After returning:

  • The controlled value prop is correct.
  • React re-renders the component with the expected props.
  • The displayed value disappears.
  • Clicking the trigger does nothing.
  • The dropdown cannot be opened.

Workaround

Forcing a remount fixes the issue:

import { usePathname } from 'next/navigation';

const pathname = usePathname();

<Select
  key={pathname}
  value={value}
  onChange={...}
/>

After remounting, the Select works correctly again.

Additional notes

  • A full page refresh fixes the problem.
  • The issue only appears after leaving the page and returning through Next.js client-side routing.
  • The issue does not happen on the initial render.
  • The problem does not seem related to the controlled state because the component receives the correct value.

Screenshots or Videos

No response

Operating System Version

macOS

Browser

Chrome

PiotrZacharskiThey avatar Aug 05 '26 08:08 PiotrZacharskiThey

  1. please try on the latest version (v3.2.3) to see if it is still reproducible
  2. if so, please share a minimal reproducible sandbox

wingkwong avatar Aug 05 '26 08:08 wingkwong

It seems that with the latest version (v3.2.3) it works without any workarounds. At least in codesandbox. Actual project to be verified.

PiotrZacharskiThey avatar Aug 10 '26 07:08 PiotrZacharskiThey