Skip to content

Fix external domain dropdown defaulting to alphabetically first instead of site-default domain#247

Open
Copilot wants to merge 3 commits intomainfrom
copilot/fix-external-domain-sorting
Open

Fix external domain dropdown defaulting to alphabetically first instead of site-default domain#247
Copilot wants to merge 3 commits intomainfrom
copilot/fix-external-domain-sorting

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

When creating/editing a container with an HTTP service, the domain dropdown was sorted alphabetically by name, causing a non-default domain to be auto-selected instead of the site's default domain.

Changes

  • routers/containers.js: Replaced ORDER BY name ASC with a partitioned sort — site-default domains (where siteId matches the current site) come first ordered by id, followed by all others ordered by id.
  • Added sortExternalDomains(domains, siteId) helper to encapsulate the single-pass partition, used by both the new and edit container routes.
function sortExternalDomains(domains, siteId) {
  const defaults = [], others = [];
  for (const domain of domains) {
    (domain.siteId === siteId ? defaults : others).push(domain);
  }
  return [...defaults, ...others];
}
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: Non-default external domain being listed first for HTTP services</issue_title>
<issue_description>### Current URL

/sites/1/containers/new

Username

rgingras

Version

a2bd601

Steps to reproduce

  1. Create or edit a container
  2. Add an HTTP service
  3. Observe non-default domain populated in the field

Expected behavior

The first default domain for the site should be populated.

Actual behavior

The alphabetically first domain is used.

Additional context

No response</issue_description>

<agent_instructions>When sorting externalDomains in the drop down, all domains that are default for the site should be sorted first, in order by database id, then all non-default domains, still in order by database id.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: runleveldev <44057501+runleveldev@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix sorting of external domains for HTTP services Fix external domain dropdown defaulting to alphabetically first instead of site-default domain Mar 19, 2026
Copilot AI requested a review from runleveldev March 19, 2026 15:25
…ains()

Co-authored-by: runleveldev <44057501+runleveldev@users.noreply.github.com>
Copy link
Collaborator

@runleveldev runleveldev left a comment

Choose a reason for hiding this comment

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

LGTM

@runleveldev runleveldev marked this pull request as ready for review March 19, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Non-default external domain being listed first for HTTP services

2 participants