Skip to content

refactor | Added a new property to expose the ability to disable the sorting#7360

Open
ByronMayne wants to merge 2 commits intoelsa-workflows:mainfrom
ByronMayne:fix/drop-down-sorting
Open

refactor | Added a new property to expose the ability to disable the sorting#7360
ByronMayne wants to merge 2 commits intoelsa-workflows:mainfrom
ByronMayne:fix/drop-down-sorting

Conversation

@ByronMayne
Copy link
Copy Markdown

Purpose

Currently the DropDown control has the following logic

   protected override void OnInitialized()
   {
       var selectList = EditorContext.InputDescriptor.GetSelectList();
       _items = selectList.Items.OrderBy(x => x.Text).ToList();
   }

Sorting by the text is not always desirable. For example I have a drop down that has a list of versions. So sorting by the Text field does not make sense anymore. If I were to rewrite this I would not add any sorting and just use the original collection order that was provided. However I don't want to break the current feature set. So I added a boolean SortItems which will allow user to disable this feature.


Scope

Select one primary concern:

  • Bug fix (behavior change)
  • Refactor (no behavior change)
  • Documentation update
  • Formatting / code cleanup
  • Dependency / build update
  • New feature

Description

Exposed a new boolean to disable sorting of items in a dropdown. The actual logic change needs to happen in Studio and that would be another PR.

Problem

Have the ability to disable the auto sorting of items in the dropdown. For example if the user case of the drop down having version numbers.

Solution

Added a boolean


Verification

Right now it's just a boolean the validation would need to come from studio

Checklist

  • The PR is focused on a single concern
  • Commit messages follow the recommended convention
  • Tests added or updated (if applicable)
  • Documentation updated (if applicable)
  • No unrelated cleanup included
  • All tests pass

This was because I don't want my items to be sorted by the control
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 14, 2026

Greptile Summary

This PR adds a SortItems boolean parameter to the API client's SelectList record, allowing consumers to opt out of alphabetical sorting in dropdown UI components. The change is limited to the data model/DTO layer — the actual sorting logic lives in the Elsa Studio (a separate repository), with a follow-up PR planned there.

  • Adds bool SortItems = false to Elsa.Api.Client.Shared.UIHints.DropDown.SelectList
  • The server-side SelectList in Elsa.Workflows.Core is not updated, which is consistent with the existing divergence pattern (e.g., IsFlagsEnum also only exists in the API client version)
  • Concern: The default value of false may cause a backward compatibility issue — since Studio currently sorts by default, a SortItems = true default would better preserve existing behavior when the Studio is updated to respect this flag

Confidence Score: 3/5

  • This PR is safe to merge as-is since it only adds a defaulted parameter to a record, but the default value choice may cause issues in the follow-up Studio PR.
  • The change is minimal and non-breaking at the compilation level. However, the semantic default of SortItems = false contradicts the current runtime sorting behavior, which could lead to a backward compatibility issue when the Studio is updated. Score reflects this design concern rather than any immediate runtime risk.
  • Pay attention to src/clients/Elsa.Api.Client/Shared/UIHints/DropDown/SelectList.cs — the default value of SortItems should be reconsidered for backward compatibility.

Important Files Changed

Filename Overview
src/clients/Elsa.Api.Client/Shared/UIHints/DropDown/SelectList.cs Adds SortItems boolean parameter to the SelectList record. Default value of false may conflict with current sorting behavior in Studio, potentially causing a backward compatibility issue when the Studio-side PR is implemented.

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class `SelectList (Api.Client)` {
        +ICollection~SelectListItem~ Items
        +bool IsFlagsEnum = false
        +bool SortItems = false ⬅ NEW
    }
    class `SelectList (Workflows.Core)` {
        +ICollection~SelectListItem~ Items
    }
    class DropDownProps {
        +SelectList? SelectList
        +string? ProviderName
    }
    class SelectListItem {
        +string Text
        +string Value
    }
    DropDownProps --> `SelectList (Api.Client)` : uses (client)
    DropDownProps --> `SelectList (Workflows.Core)` : uses (server)
    `SelectList (Api.Client)` --> SelectListItem : contains
    `SelectList (Workflows.Core)` --> SelectListItem : contains
Loading

Last reviewed commit: 3aba559

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
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