fix(Designer): Add null safety to localeCompare in connection flow#8985
Merged
fix(Designer): Add null safety to localeCompare in connection flow#8985
Conversation
The resourcefield.tsx and selectConnection.helpers.ts sort comparators were calling localeCompare on potentially undefined displayName values, causing a TypeError that crashes the connection creation panel. This manifests as 'renderComponentIntoRoot encountered an error' in the Azure Portal. Adds nullish coalescing to both sides of the comparison in both designer and designer-v2, matching the pattern from PR #8949. Fixes ICM 761274226
🤖 AI PR Validation ReportPR Review ResultsThank you for your submission! Here's detailed feedback on your PR title and body compliance:✅ PR Title
✅ Commit Type
✅ Risk Level
✅ What & Why
|
| Section | Status | Recommendation |
|---|---|---|
| Title | ✅ | Title is good. |
| Commit Type | ✅ | Correct (fix). |
| Risk Level | ✅ | risk:low is appropriate. |
| What & Why | ✅ | Clear and adequate. |
| Impact of Change | Add note about potential array-mutation impact. | |
| Test Plan | Add a unit test for comparator or expand manual test details. | |
| Contributors | Optional: add other contributors if applicable. | |
| Screenshots/Videos | ✅ | N/A is fine. |
Final notes & recommended action items
- Overall: ✅ This PR passes the PR title/body checks and the advised risk level is
risk:low, which matches the label on the PR. - Code-style suggestion (important): In the diff you use resources.sort(...). Array.prototype.sort mutates the input array in-place — if
resourcesis a prop or shared reference this can cause surprising side effects. Please consider changing to an immutable sort to avoid mutating the original array, e.g.:const sortedResources = useMemo(() => [...resources].sort((a, b) => (a.displayName ?? '').localeCompare(b.displayName ?? '')), [resources]);- and similarly for other occurrences if applicable.
- Testing: Please add a small unit test that verifies compare behavior when displayName is undefined/null to avoid regressions in future refactors. If you cannot add a unit test, expand the Test Plan with exact manual steps and environments you used to validate the fix.
Please update the PR with the test addition (or expanded Test Plan) and consider the immutable sort change. Once those are addressed you'll be good to merge. Thank you for the clear description and small, focused fix!
Last updated: Mon, 30 Mar 2026 22:02:22 GMT
Elaina-Lee
approved these changes
Mar 30, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a crash in the connections and resource picker flows by making string sorting resilient to missing displayName values, in both Designer (v1) and Designer V2.
Changes:
- Add null-safe
localeCompareusage in connection sorting comparators. - Add null-safe
localeCompareusage in resource dropdown sorting.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| libs/designer/src/lib/ui/panel/connectionsPanel/selectConnection/selectConnection.helpers.ts | Makes connection comparator tolerant of missing displayName. |
| libs/designer/src/lib/ui/common/resourcepicker/resourcefield.tsx | Makes resource dropdown sorting tolerant of missing displayName. |
| libs/designer-v2/src/lib/ui/panel/connectionsPanel/selectConnection/selectConnection.helpers.ts | Mirrors the connection comparator null-safety in Designer V2. |
| libs/designer-v2/src/lib/ui/common/resourcepicker/resourcefield.tsx | Mirrors the resource dropdown sorting null-safety in Designer V2. |
libs/designer/src/lib/ui/panel/connectionsPanel/selectConnection/selectConnection.helpers.ts
Show resolved
Hide resolved
libs/designer-v2/src/lib/ui/panel/connectionsPanel/selectConnection/selectConnection.helpers.ts
Show resolved
Hide resolved
takyyon
approved these changes
Mar 30, 2026
📊 Coverage Check🎉 All changed files have adequate test coverage! |
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.
Commit Type
Risk Level
What & Why
The resourcefield.tsx and selectConnection.helpers.ts sort comparators were calling localeCompare on potentially undefined displayName values, causing a TypeError that crashes the connection creation panel. This manifests as 'renderComponentIntoRoot encountered an error' in the Azure Portal.
Adds nullish coalescing to both sides of the comparison in both designer and designer-v2, matching the pattern from PR #8949.
Fixes ICM 761274226
Impact of Change
Test Plan
Simple null catches, no further test file changes needed
Contributors
@rllyy97
Screenshots/Videos
N/A