Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
`<details>` element behaves incorrectly in Next.js 14/15 | GoodFirstPicks

`<details>` element behaves incorrectly in Next.js 14/15

vercel/next.js 6 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeTest focusedNext.jsTypeScriptReact

Why this is a good first issue

The issue involves inconsistent behavior of the `<details>` element's `onToggle` event between Next.js and standard React/HTML.

AI Summary

The issue reports that the `<details>` element's `onToggle` event does not fire automatically on render in Next.js 14/15 when `open` is set to `true`, contrary to standard HTML and React behavior. The problem requires investigation into Next.js's handling of DOM events and potential server-side rendering implications. Recent comments suggest it might be related to client-side behavior but remain inconclusive.

Issue Description

Link to the code that reproduces this issue

https://github.com/mikedidomizio/details-element-in-Next-14

To Reproduce

First sorry that the GitHub link is for Next14, it doesn't matter here

The <details> HTML element is an accordion style HTML tag that can show and hide information.

The onToggle event is expected to automatically fire on render if open is set to true Documentation

In the example above the event listener will be called once without any user interaction because the open attribute is set.

Below are CodeSandbox examples, the way to see if it automatically fire is to open the developer tools console and see that a console.log is either done or not.

In HTML it works that way ✅

In React 19 it works that way ✅

In React 18 it works that way ✅

In Next.js 15 it doesn't seem to work that way 🤔

In Next.js 14 it doesn't seem to work that way 🤔

So HTML/React will automatically trigger the onToggle event on render if open is set to true, but not Next.js.

Is this a bug or am I doing something wrong with the Next example?

(Originally posted on the Discord/Forum)

https://github.com/user-attachments/assets/f70b5f76-e31a-4072-8de8-35a6ace844f6

Current vs. Expected behavior

Current behaviour:

  • Unles

GitHub Labels

bug

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • server-side vs client-side behavior
  • React version dependencies
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedyes
AssigneeicyJoseph