Interfaces not sorted in natural order in cable connection interface selection #5373

Closed
opened 2025-12-29 19:27:15 +01:00 by adam · 1 comment
Owner

Originally created by @candlerb on GitHub (Sep 15, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.0.2

Python version

3.8

Steps to Reproduce

  1. Create two devices
  2. On the first device, click the Connect cable button and select "Interface"
  3. In the B side dialog, enter the second device name, and then select from the list of interfaces

Expected Behavior

Interfaces to be displayed in "natural" order, i.e. the same as in the main interface listing

(In my test I was using a Netgear switch with interfaces 0/1, 0/2, ... 0/9, 0/10, 0/11, .... 0/19, 0/20, 0/21 ...)

Observed Behavior

Interfaces are shown in "alphabetical" order, e.g. 0/19 comes before 0/2

image

Originally created by @candlerb on GitHub (Sep 15, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.0.2 ### Python version 3.8 ### Steps to Reproduce 1. Create two devices 2. On the first device, click the Connect cable button and select "Interface" 3. In the B side dialog, enter the second device name, and then select from the list of interfaces ### Expected Behavior Interfaces to be displayed in "natural" order, i.e. the same as in the main interface listing (In my test I was using a Netgear switch with interfaces 0/1, 0/2, ... 0/9, 0/10, 0/11, .... 0/19, 0/20, 0/21 ...) ### Observed Behavior Interfaces are shown in "alphabetical" order, e.g. 0/19 comes before 0/2 ![image](https://user-images.githubusercontent.com/44789/133431523-dda00950-7444-431a-b717-2963a519c33e.png)
adam added the type: bugstatus: accepted labels 2025-12-29 19:27:15 +01:00
adam closed this issue 2025-12-29 19:27:15 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 15, 2021):

It looks like the <select> options are being automatically sorted by the front end. AFAICT this should never be needed, since the REST API returns these already in order, but I could be mistaken. @thatmattlove do you know of any instances where this is needed?

Maybe we should at least invert this behavior, and sort only where we know it's necessary.

@jeremystretch commented on GitHub (Sep 15, 2021): It looks like the `<select>` options are being [automatically sorted](https://github.com/netbox-community/netbox/blob/baf045aed656b20e2fb473b2642adb9193076d0b/netbox/project-static/src/select/api/apiSelect.ts#L157) by the front end. AFAICT this should never be needed, since the REST API returns these already in order, but I could be mistaken. @thatmattlove do you know of any instances where this is needed? Maybe we should at least invert this behavior, and sort only where we know it's necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5373