Skip to content

docs: add native DOM examples to Activity guide - #101581

Merged
aurorascharff merged 13 commits into
canaryfrom
codex/activity-native-dom-examples
Nov 12, 2026
Merged

aurorascharff merged 13 commits into
canaryfrom
codex/activity-native-dom-examples

Conversation

@aurorascharff

@aurorascharff aurorascharff commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the native popover example from #100208 to the existing Activity guide, with cleanup and unique IDs for elements in preserved pages. Also corrects the form-reset example to keep its callback ref stable across rerenders and distinguishes uncontrolled DOM values from controlled React state. Clarifies that an Effect running again does not necessarily mean a page was shown again, because Strict Mode also repeats setup and cleanup in development.

Verification

  • Checked the examples against React's Activity cleanup implementation and the React and MDN API references.
  • Prettier and git diff --check pass.
  • Browser tests were not run for this docs-only change.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 450f4d1
View workflow run

@github-actions github-actions Bot added the Documentation Related to Next.js' official documentation. label Nov 11, 2026

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed 44a5222 and found no issues.

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed 3eb0a73 and found no issues.

@aurorascharff
aurorascharff marked this pull request as ready for review November 11, 2026 14:50

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed 81b1f53 and found no issues.

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed 3cb6396 and found no issues.

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed 79e4cd6 and found no issues.

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed 0f73e76 and found no issues.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

All broken links are now fixed, thank you!

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed 1569c1b and found no issues.

```tsx highlight={3,7-9,20,25}
If a dialog should open when visiting a particular URL, derive its state from a search parameter. For example, this dialog opens when the URL includes `?edit=true`:

```tsx highlight={7-9,15-17,28,33}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This highlights:

  return (
    <Suspense fallback={null}>
      <ProductDialog />

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, i didnt reread the diff after having an agent try to build the examples. apparently it did a terrible job

```

With this approach, `isDialogOpen` derives from the URL rather than component state. When navigating away and returning, the search param is cleared (the URL changed), so `isDialogOpen` becomes `false`. Opening the dialog sets the param, which changes `isDialogOpen` and triggers the Effect.
The [`Suspense` boundary](/docs/app/api-reference/functions/use-search-params#prerendering) lets the rest of the page prerender while the dialog reads the current search parameters.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not correct anymore-ish... we can and should refactor so that the edit product button is a sibling to the boundary.

And, idk, this is not a Page or Layout, it is a contained piece of UI, who ever renders it could take care of the Suspense boundary placement. It depends.

```

This resets all fields whenever the user navigates away.
Defining the callback outside the component keeps it stable across re-renders. `form.reset()` does not reset React state. For controlled inputs, reset the state passed to `value` or `checked`, as in the examples above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we say why keep it stable? no?

**When to keep it:** A sidebar with expanded sections, a FAQ accordion, or a filters panel. The user set up their view intentionally, and restoring it avoids re-doing that work.

**When to reset it:** A dropdown menu or popover triggered by a button click. These are transient interactions, not persistent view state. Returning to a page with a dropdown already open is not user friendly.
**When to reset it:** A dropdown menu or popover triggered by a button click, for example. These are transient interactions, not persistent view state. Returning to a page with a dropdown already open can be confusing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we keep the previous version? the , for example is odd, and calling it confusing mm perhaps

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed 5e5f069 and found no issues.

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed 486fb62 and found no issues.

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed cc14bf1 and found no issues.

@aurorascharff
aurorascharff enabled auto-merge (squash) November 12, 2026 12:32

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed 7f41472 and found no issues.

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed ca7ca85 and found no issues.

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vercel Agent reviewed 450f4d1 and found no issues.

@aurorascharff
aurorascharff merged commit 9d9c204 into canary Nov 12, 2026
58 checks passed
@aurorascharff
aurorascharff deleted the codex/activity-native-dom-examples branch November 12, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Related to Next.js' official documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants