Skip to content

fix: numeric sorting of tool macros in spoolman card#1763

Merged
pedrolamas merged 5 commits intofluidd-core:developfrom
wasikuss:spoolman-numeric-sort
Dec 16, 2025
Merged

fix: numeric sorting of tool macros in spoolman card#1763
pedrolamas merged 5 commits intofluidd-core:developfrom
wasikuss:spoolman-numeric-sort

Conversation

@wasikuss
Copy link
Contributor

The drop-down for changing spools on multi tool machine is sorted without taking care of numbers.

Before
scr_2025-12-09_at_22 55 40

After:
Screenshot 2025-12-15 135814

Signed-off-by: Krzysztof Wasilewski wasikuss@gmail.com

Signed-off-by: wasikuss <wasikuss@gmail.com>
@pedrolamas pedrolamas added the GH - Bug Something isn't working label Dec 16, 2025
@pedrolamas pedrolamas added this to the 1.36.1 milestone Dec 16, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes numeric sorting of tool macros in the Spoolman card dropdown, ensuring names like "T1", "T2", "T10" sort correctly (1, 2, 10) instead of alphabetically (1, 10, 2).

  • Replaced simple case-insensitive string comparison with localeCompare using numeric: true option for natural number sorting

.filter((macro): macro is MacroWithSpoolId => macro.variables != null && 'spool_id' in macro.variables)
.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()))
.sort((a, b) => a.name.localeCompare(b.name, undefined, {
sensitivity: 'accent',
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The sensitivity: 'accent' option makes the sort case-sensitive, which changes the existing behavior. The original code used toLowerCase() to ensure case-insensitive sorting. To maintain case-insensitive sorting while adding numeric support, use sensitivity: 'base' instead of sensitivity: 'accent'.

With 'accent': "Tool 10" would sort differently from "tool 10"
With 'base': "Tool 10" and "tool 10" are treated as equal (case-insensitive)

Suggested change
sensitivity: 'accent',
sensitivity: 'base',

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

I've removed the sensitivity as this is not necessary; when using numeric: true, that will already cause a case-insensitive comparison.

Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@pedrolamas pedrolamas merged commit 70dd0e0 into fluidd-core:develop Dec 16, 2025
4 checks passed
@wasikuss wasikuss deleted the spoolman-numeric-sort branch December 29, 2025 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GH - Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants