Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export function useDatasetOptions(fields: IExtraField[]) {
}, [hasDatasetFields, isDatasetsLoaded, isDatasetsLoading, dispatch]);

return useMemo(
() => 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.

[datasetsList],
);
}
4 changes: 2 additions & 2 deletions frontend/src/public/utils/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export function getSortedAndFilteredDatasetItems(

result.sort((a, b) => {
if (sorting === EDatasetsSorting.NameAsc) {
return a.value.localeCompare(b.value);
return a.value.localeCompare(b.value, undefined, { numeric: true });
}
if (sorting === EDatasetsSorting.NameDesc) {
return b.value.localeCompare(a.value);
return b.value.localeCompare(a.value, undefined, { numeric: true });
}
if (sorting === EDatasetsSorting.DateAsc) {
return a.order - b.order;
Expand Down