Skip to content

46276 frontend [ datasets ] improvements to the dataset#207

Open
Maria-Lordwill wants to merge 3 commits into
masterfrom
frontend/datasets/46276__fix_the_sorting_of_elements_in_the_dataset
Open

46276 frontend [ datasets ] improvements to the dataset#207
Maria-Lordwill wants to merge 3 commits into
masterfrom
frontend/datasets/46276__fix_the_sorting_of_elements_in_the_dataset

Conversation

@Maria-Lordwill
Copy link
Copy Markdown
Collaborator

@Maria-Lordwill Maria-Lordwill commented Apr 29, 2026

1. Release notes

  • Fixed dataset item sorting by name: numbers are now sorted naturally (1, 2, 10 instead of 1, 10, 2).
  • Empty datasets (with no items) are no longer shown in the dataset selection menu in the template editor.

2. Description (problem)

Sorting: On the dataset details page, sorting items by name produced lexicographic order for numeric values: 1, 10, 2, 20, 3. This is the default localeCompare behavior without the numeric option, but it is unintuitive for users.

Empty datasets: In the template editor, the field hamburger menu (dropdown/checkbox/radio) allowed selecting a dataset with zero items. After saving the template, the Run form displayed such a field as empty — only the field name with no options.

3. Context

  • Dataset details page: /datasets/:id — item sorting.
  • Template editor: field hamburger menu for dropdown/checkbox/radio types — "Dataset" submenu with available datasets.
  • Affected components: KickoffRedux (kickoff fields) and OutputForm (task fields) — both use the shared useDatasetOptions hook.

4. Solution

Sorting: Added { numeric: true } option to localeCompare for name-based sorting — numbers within strings are now compared as numbers.

Empty datasets: Added .filter(({ itemsCount }) => itemsCount > 0) in the useDatasetOptions hook before building the options list. The itemsCount field was already provided by the backend in the datasets list API response and defined in the IDatasetListItem type, but was not previously used.

5. What to test

5.1 Preconditions

  • Several datasets available, including: a dataset with numeric items (1, 2, 10, 20, 100), an empty dataset (no items), and a dataset with items.
  • Testing in Desktop Chromium. Safari, Firefox, Mobile — delegated to QA.

5.2 Positive scenarios

Scenario Description (steps and expected result) Checked by Dev (desktop) Checked by Dev (mobile) Checked by AI Agent (Chromium)
Natural sort by name Go to dataset details with numeric items (1, 2, 10, 20, 100). Select "Name A→Z" sorting. → Items are displayed in order: 1, 2, 10, 20, 100. [ ] [ ] [ ]
Reverse natural sort In the same dataset, select "Name Z→A". → Items in order: 100, 20, 10, 2, 1. [ ] [ ] [ ]
Text sorting still works Go to a dataset with text items (Apple, Banana, Cherry). Select "Name A→Z". → Alphabetical order is preserved. [ ] [ ] [ ]
Empty dataset hidden in menu Open the template editor. Add a dropdown field. Click hamburger menu → "Dataset". → The empty dataset is not shown in the list. [ ] [ ] [ ]
Non-empty datasets visible In the same "Dataset" submenu → non-empty datasets are displayed and selectable. [ ] [ ] [ ]

5.3 Negative scenarios and edge cases

Scenario Description (steps and expected result) Checked by Dev (desktop) Checked by Dev (mobile) Checked by AI Agent (Chromium)
All datasets are empty Create only empty datasets. Open hamburger menu for a dropdown field → "Dataset". → Submenu does not expand (no available options), the item is displayed as disabled/grayed out. [ ] [ ] [ ]
Add item to empty dataset Go to an empty dataset, add an item, return to the template editor. → The dataset now appears in the "Dataset" submenu. [ ] [ ] [ ]
Mixed numbers and text Dataset with items: "item1", "item2", "item10". Sort "Name A→Z". → Order: item1, item2, item10. [ ] [ ] [ ]

5.4 Verification points

  • UI: item order on the dataset details page under different sort modes.
  • UI: contents of the "Dataset" submenu in the field hamburger menu in the template editor.

5.5 What was NOT tested

  • Locales (en/ru) — out of scope.
  • Sort by date — not changed.
  • Mobile layout — delegated to QA.

6. Commits

  • 01246fd746276 fix(datasets): use natural sort order for dataset items (1, 2, 10 instead of 1, 10, 2)
  • 25431ea946276 fix(datasets): hide empty datasets from selection menu in template editor

Commit 1a1836fd (disabled support for Dropdown) was reverted as part of 25431ea9 — business decided to hide empty datasets rather than disable them.

Note

Cursor Bugbot is generating a summary for commit 01246fd. Configure here.

Note

Filter empty datasets and fix numeric name sorting in dataset options

  • useDatasetOptions now excludes datasets with zero items from the selectable options list.
  • getSortedAndFilteredDatasetItems uses localeCompare with numeric: true for name-based sorting, so values like '2' and '10' sort in natural numeric order.
  • Behavioral Change: datasets with itemsCount === 0 no longer appear as selectable options; name sort order may change for values containing numbers.

Macroscope summarized 25431ea.

@Maria-Lordwill Maria-Lordwill added bug Something isn't working Frontend Web client changes request labels Apr 29, 2026
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 25431ea. Configure here.

() => datasetsList.map((dataset) => ({ label: dataset.name, value: String(dataset.id) })),
() => datasetsList
.filter(({ itemsCount }) => itemsCount > 0)
.map(({ name, id }) => ({ label: name, value: String(id) })),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Empty datasets filtered out instead of shown disabled

Medium Severity

The .filter(({ itemsCount }) => itemsCount > 0) call removes datasets with zero items from the options entirely, but the PR intent is to render them as disabled (visually muted, non-clickable, with aria-disabled). Filtering contradicts the stated behavior — empty datasets become invisible rather than disabled. Additionally, if a field already references a dataset whose items were later deleted, that dataset silently disappears from the dropdown, leaving the user unable to see or change the current selection.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 25431ea. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Frontend Web client changes request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant