fix: auto-run search when opening auto-add modal#151
Merged
Conversation
When handleOpenAutoAdd() pre-fills the substring input with the alias ID, the search was never executed — the modal opened with the query visible but results empty, requiring a manual click of the Search button. Fix: accept an optional query param in handleSearchModels() so the caller can supply the value directly rather than relying on the React state that hasn't updated yet. handleOpenAutoAdd() now passes the query string inline, triggering results immediately on modal open. Also move handleSearchModels above handleOpenAutoAdd so the const reference is valid at the call site.
github-actions bot
pushed a commit
that referenced
this pull request
Apr 6, 2026
When handleOpenAutoAdd() pre-fills the substring input with the alias ID, the search was never executed — the modal opened with the query visible but results empty, requiring a manual click of the Search button. Fix: accept an optional query param in handleSearchModels() so the caller can supply the value directly rather than relying on the React state that hasn't updated yet. handleOpenAutoAdd() now passes the query string inline, triggering results immediately on modal open. Also move handleSearchModels above handleOpenAutoAdd so the const reference is valid at the call site.
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.
Fixes #148
Problem
When clicking the auto-add target button, the modal opens with the alias ID pre-filled in the search input, but no results are shown. The user has to manually click the Search button to get results, which is not obvious.
Root cause:
handleOpenAutoAdd()calledsetSubstring()andsetIsAutoAddModalOpen(true)but never executed the search. CallinghandleSearchModels()immediately aftersetSubstring()would also not work since React state updates are batched —substringstill holds the old value at that point.Fix
handleSearchModelsnow accepts an optionalqueryparameter. When supplied it uses that value directly instead of reading from the (potentially stale)substringstate. Existing callsites (Enter key, Search button) are unaffected — they still call it with no args.handleOpenAutoAddcaptures the query in a local variable, sets state, then callshandleSearchModels(query)directly — no timing issues, no duplicated logic.handleSearchModelsabovehandleOpenAutoAddso theconstreference is valid at the call site.Behaviour after fix
Opening the auto-add modal immediately shows matching models for the pre-filled alias ID. The Search button and Enter key continue to work as before.