refactor: control create-reference dialog with local state instead of url#1117
Merged
igboyes merged 4 commits intoJul 8, 2026
Conversation
… 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.
There was a problem hiding this comment.
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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
💡 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".
…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.
Member
Author
|
Re Sourcery's review:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/refsURL search params and into local React state, since it's transient UI state rather than something that needs to be shareable or bookmarkableEmptyReferenceandImportReferenceforms into a singleCreateReferenceFormsharing 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