Skip to content

fix(scripting): sort selected devices by name when added - #1167

Merged
JamieRuderman merged 3 commits into
mainfrom
fix/sort-scripting-device-selection
Aug 3, 2026
Merged

fix(scripting): sort selected devices by name when added#1167
JamieRuderman merged 3 commits into
mainfrom
fix/sort-scripting-device-selection

Conversation

@JamieRuderman

Copy link
Copy Markdown
Member

Devices selected for a script run were kept in click order (or, for select-all, whatever sort the device list happened to be using). That order carried straight through to the created job, so the Targets chips and the Devices list on the job detail page came out unsorted.

Sorting once at selection time means the order is right from the first click and nothing has to re-sort later — the run form chips, the submitted deviceIds, and the resulting job all inherit it.

Changes

  • sortSelectedIds(selected, devices) added to helpers/selectionRange.ts, alongside the existing mergeSelectedIds/removeSelectedIds. Uses localeCompare with numeric: true so dozer-2 sorts ahead of dozer-10.
  • Applied at the two places the device list writes to ui.selected: useSelect (click and shift-range) and DeviceListHeaderCheckbox (select-all).

DeviceScriptingMenu sets a single id, so it needs no sort. Nothing in the job fetch or socket-update path was touched — existing jobs render exactly as before.

Notes

  • ui.selected is shared with the other bulk device actions (tagging, transfer, delete), so those selections are name-ordered now too.
  • Names resolve from the visible device list; a selected device filtered out of view falls back to sorting on its raw id. Only reachable by changing the filter mid-selection.

Testing

  • tsc --noEmit passes.
  • Not exercised in the running app — worth a quick manual check that the created job's device order comes back sorted, in case the API re-orders jobDevices on its own.

@aws-amplify-us-west-1

Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-1167.d20k671nqqv4kl.amplifyapp.com

@JamieRuderman
JamieRuderman merged commit 3175053 into main Aug 3, 2026
8 checks passed
@JamieRuderman
JamieRuderman deleted the fix/sort-scripting-device-selection branch August 3, 2026 19:34
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.

1 participant