[BUG] - Select becomes unusable after Next.js App Router client-side navigation
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
valueprop 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
- Next.js App Router
- React Client Component
@heroui/[email protected]
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
- 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>
);
}
- Navigate to another route using Next.js client-side navigation:
<Link href="/another-page">
Open another page
</Link>
- Navigate back to the original page using another Next.js
Link:
<Link href="/original-page">
Go back
</Link>
- 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
valueprop 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
- please try on the latest version (v3.2.3) to see if it is still reproducible
- if so, please share a minimal reproducible sandbox
It seems that with the latest version (v3.2.3) it works without any workarounds. At least in codesandbox. Actual project to be verified.