fix(integrations): preserve async select value in external issue modal after dynamic refetch#115593
Merged
Conversation
Contributor
📊 Type Coverage Diff
🔍 1 new type safety issue introducedType assertions (
This is informational only and does not block the PR. |
nora-shap
approved these changes
May 14, 2026
Comment on lines
+157
to
+165
| const handleAsyncOptionsFetched = useCallback( | ||
| (fieldName: string, options: Array<SelectValue<string>>) => { | ||
| setAsyncOptionsCache(prev => ({ | ||
| ...prev, | ||
| [fieldName]: options.map((o): Choice => { | ||
| const label = typeof o.label === 'string' ? o.label : String(o.value); | ||
| return [o.value, label]; | ||
| }), | ||
| })); |
Contributor
There was a problem hiding this comment.
Bug: The handleAsyncOptionsFetched callback overwrites the async option cache on each search, which can cause selected option labels to disappear after a subsequent form remount.
Severity: MEDIUM
Suggested Fix
Modify handleAsyncOptionsFetched to merge new options with the existing options in asyncOptionsCache[fieldName] instead of completely replacing them. This ensures that previously selected values are retained in the cache across searches and subsequent form remounts, even if they don't appear in newer search results.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: static/app/components/externalIssues/externalIssueForm.tsx#L157-L165
Potential issue: The `handleAsyncOptionsFetched` callback completely replaces the
`asyncOptionsCache` for a given field with each new set of search results. If a user
selects an option from an async search (e.g., a specific Jira project), then performs a
second search in the same field whose results do not include the selected option, the
cache entry for the selected option is lost. If the form later remounts due to another
field changing, the UI will no longer have the label for the selected option, showing a
raw ID instead. This is a regression of the bug this PR intended to fix.
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.
Previously, selecting a Jira project via async search (one not in the initial dropdown) would lose the selection after the form refreshed — the value was preserved but the label couldn't display because the option wasn't in the static choices list. This regressed in #112094, which migrated the external issue form but dropped the async options caching the old implementation relied on.
In this PR,
externalIssueForm.tsxhas been updated so async search results are cached and merged into field choices across form remounts, matching the pattern #115456 already applied toticketRuleModal.tsx. Also added a test covering the full async search + dynamic refetch + form remount cycle to prevent future regressions.