IdP create form is dirty immediately (dev only)

Open
#2,913 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

Research direction

Start in app/forms/idp/create.tsx at lines 77-89 and inspect the effect that calls setValue. Reproduce the form in development with React Strict Mode enabled, then verify that leaving an untouched form no longer triggers a navigation confirmation and that the value still initializes correctly.

Written by the indexing model from the issue text.

Description

Bug found while working on #2912, but it turns out to happen on main, too. This only happens in dev, so it's very low priority.

https://github.com/oxidecomputer/console/blob/5c393b4dea3f525df3f62cf07ae451e391381040/app/forms/idp/create.tsx#L77-L89

This effect is causing the form to become dirty on initial mount, causing a nav confirm when you try to leave the form, even though you haven't done anything. Key facts:

  • I know it's that setValue because when I comment it out the problem goes away
  • This is only true in development, where React's strict mode is running all effects twice, so it's probably some kind of race
  • Adding { shouldDirty: false } to the setValue does not help (setValue docs)
Image
Dominant language
TypeScript
Stars
228
Forks
22
Avg merge
19h 42m
Merged PRs (30d)
32

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from oxidecomputer/console

All issues in oxidecomputer/console

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.