Skip to content

refactor: control create-reference dialog with local state instead of url#1117

Merged
igboyes merged 4 commits into
mainfrom
igboyes/vir-2611-control-createreferencetype-with-react-state-instead-of-url
Jul 8, 2026
Merged

refactor: control create-reference dialog with local state instead of url#1117
igboyes merged 4 commits into
mainfrom
igboyes/vir-2611-control-createreferencetype-with-react-state-instead-of-url

Conversation

@igboyes

@igboyes igboyes commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

  • Move the create-reference dialog's open/closed state and empty/import mode off the /refs URL search params and into local React state, since it's transient UI state rather than something that needs to be shareable or bookmarkable
  • Merge the previously independent EmptyReference and ImportReference forms into a single CreateReferenceForm sharing one react-hook-form instance, fixing lost input when switching modes and a duplicate DOM id that surfaced once both forms could mount at once

igboyes added 2 commits July 8, 2026 10:11
… url

Move the create-reference dialog's open state and empty/import tab
selection off the /refs URL search params and into local React state,
since it's transient UI state rather than something that needs to be
shareable or bookmarkable. The empty/import tab switch now uses the
local-state Tabs component instead of the routing-based NavTab, with
both panes kept mounted so in-progress input isn't lost when switching
tabs. Also fixes a duplicate DOM id (name/description fields) that
surfaced once both forms could be mounted simultaneously.
EmptyReference and ImportReference were two independent forms, so
switching between them lost whatever had been typed. Merge them into
one CreateReferenceForm with a single react-hook-form instance shared
across modes, and swap the empty/import tabs for a ToggleGroup mode
switch since these were never really independent content panes -
just two variants of the same form.
@linear-code

linear-code Bot commented Jul 8, 2026

Copy link
Copy Markdown

VIR-2611

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • CreateReferenceForm reimplements the shared name/organism/description fields already encapsulated in ReferenceForm; consider reusing ReferenceForm or extracting a smaller shared field component to avoid duplication and keep future validation/field changes in one place.
  • In CreateReferenceForm.onSubmit for import mode, the early return when uploadId is null silently does nothing; consider surfacing a user-visible error (or leveraging react-hook-form errors) for the "upload" field when the upload is missing or failed so the user understands why nothing happened.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- CreateReferenceForm reimplements the shared name/organism/description fields already encapsulated in ReferenceForm; consider reusing ReferenceForm or extracting a smaller shared field component to avoid duplication and keep future validation/field changes in one place.
- In CreateReferenceForm.onSubmit for import mode, the early return when uploadId is null silently does nothing; consider surfacing a user-visible error (or leveraging react-hook-form errors) for the "upload" field when the upload is missing or failed so the user understands why nothing happened.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f45dca02c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

igboyes added 2 commits July 8, 2026 10:29
…tton

Swap the create-reference method toggle for the existing SelectBox
component so each option carries a description instead of just a
label, and drop the now-redundant import alert. Also make the submit
button always read "Create" instead of switching text by method.
…d finishes

Address PR review feedback: submitting the import form while the
upload is still in flight (form validation passes once a file is
chosen, before its upload resolves) silently did nothing. Surface a
field error instead. Also switch CreateReference tests to
renderWithRouter for consistency, since CreateReferenceForm calls
useNavigate.
@igboyes

igboyes commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Re Sourcery's review:

  • Silent no-op on submit before upload finishes: fixed in e5e6ee0 — surfaces a "Please wait for the upload to finish" error on the upload field instead of silently returning.
  • Reusing ReferenceForm for name/organism/description: kept the duplication intentionally. ReferenceForm's FormValues/register are fixed to {name, description, organism} and shared with the unrelated edit-reference flow; CreateReferenceForm's form also carries an upload field for import mode, so reusing it would mean widening ReferenceForm's generic to fit a flow it doesn't need. Three duplicated input blocks felt like a smaller cost than that coupling.

@igboyes igboyes merged commit bc4d2fd into main Jul 8, 2026
10 checks passed
@igboyes igboyes deleted the igboyes/vir-2611-control-createreferencetype-with-react-state-instead-of-url branch July 8, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant