From 96e198a8625ddc2c93d61f8773936438781358ae Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 17:01:10 +0000 Subject: [PATCH 1/5] fix(components, plugin-list): the sort builder words a numeric sort direction as size SortBuilder kept its own direction table that knew only date and datetime, so a number, percent, progress or currency level read A to Z while the list's sort chip read Low to High. The wording now lives beside SortBuilder (sortWording + sortDirectionLabel over the listConditions.sort keys) and the list conditions read it from there. Claude-Session: https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW --- ...r-date-direction-duplicates-27520.test.tsx | 24 +++++++ .../components/src/custom/sort-builder.tsx | 66 +++++++++++++++---- .../src/conditions/ListConditionControls.tsx | 13 ---- .../__tests__/listConditions.test.tsx | 4 +- .../src/conditions/conditionModel.ts | 9 --- 5 files changed, 78 insertions(+), 38 deletions(-) diff --git a/ui/packages/components/src/__tests__/sort-builder-date-direction-duplicates-27520.test.tsx b/ui/packages/components/src/__tests__/sort-builder-date-direction-duplicates-27520.test.tsx index 44c34091c9d..895451b986a 100644 --- a/ui/packages/components/src/__tests__/sort-builder-date-direction-duplicates-27520.test.tsx +++ b/ui/packages/components/src/__tests__/sort-builder-date-direction-duplicates-27520.test.tsx @@ -139,3 +139,27 @@ describe('SortBuilder keeps one row per field (objectstack#27520 row 7)', () => expect(screen.getByRole('button', { name: /add sort/i })).toBeEnabled(); }); }); + +describe('SortBuilder names a numeric sort as size, from the chip\'s own table', () => { + const NUMERIC: Fields = [ + { value: 'title', label: 'Title', type: 'text' }, + { value: 'due_date', label: 'Due Date', type: 'date' }, + { value: 'estimate_hours', label: 'Estimate', type: 'number' }, + { value: 'progress', label: 'Progress', type: 'progress' }, + { value: 'completion', label: 'Completion', type: 'percent' }, + { value: 'budget', label: 'Budget', type: 'currency' }, + ]; + const optionLabels = (i: number) => optionsOf(directionTriggers()[i]).map((o) => o.label); + + it('number, progress, percent and currency rows read "Low → High" / "High → Low"', () => { + mount([asc('estimate_hours'), asc('progress'), asc('completion'), { field: 'budget', order: 'desc' }], NUMERIC); + for (const i of [0, 1, 2, 3]) expect(optionLabels(i)).toEqual(['Low → High', 'High → Low']); + expect(directionTriggers()[3]).toHaveTextContent('High → Low'); + }); + + it('CONTROL: beside them a date keeps time and text keeps the alphabet', () => { + mount([asc('due_date'), asc('title'), asc('estimate_hours')], NUMERIC); + expect(optionLabels(0)).toEqual(['Oldest → Newest', 'Newest → Oldest']); + expect(optionLabels(1)).toEqual(['A → Z', 'Z → A']); + }); +}); diff --git a/ui/packages/components/src/custom/sort-builder.tsx b/ui/packages/components/src/custom/sort-builder.tsx index dcf0479ba11..469a1983609 100644 --- a/ui/packages/components/src/custom/sort-builder.tsx +++ b/ui/packages/components/src/custom/sort-builder.tsx @@ -9,6 +9,7 @@ import * as React from "react" import { X, Plus, GripVertical } from "lucide-react" import { createSafeTranslation } from "@object-ui/i18n" +import { FILTER_DATE_LIKE_TYPES, FILTER_NUMBER_LIKE_TYPES } from "@object-ui/types" import type { SortItem as SpecSortItem } from "@objectstack/spec/shared" import { cn } from "../lib/utils" @@ -20,10 +21,12 @@ const useSafeSortTranslation = createSafeTranslation( 'sortBuilder.sortBy': 'Sort by', 'sortBuilder.thenBy': 'Then by', 'sortBuilder.selectField': 'Select field', - 'sortBuilder.ascending': 'A → Z', - 'sortBuilder.descending': 'Z → A', - 'sortBuilder.oldestFirst': 'Oldest → Newest', - 'sortBuilder.newestFirst': 'Newest → Oldest', + 'listConditions.sort.time_asc': 'Oldest → Newest', + 'listConditions.sort.time_desc': 'Newest → Oldest', + 'listConditions.sort.size_asc': 'Low → High', + 'listConditions.sort.size_desc': 'High → Low', + 'listConditions.sort.alphabet_asc': 'A → Z', + 'listConditions.sort.alphabet_desc': 'Z → A', 'sortBuilder.addSort': 'Add sort', 'sortBuilder.removeSort': 'Remove sort', 'sortBuilder.reorder': 'Drag to reorder', @@ -31,8 +34,42 @@ const useSafeSortTranslation = createSafeTranslation( 'sortBuilder.sortBy', ) -/** Field types whose order is time: their direction reads "Oldest → Newest". */ -const DATE_SORT_TYPES = new Set(['date', 'datetime']) +/** The direction words a sort level uses, by field type: time, size or the alphabet. */ +export type SortWording = 'time' | 'size' | 'alphabet' + +/** Ordered by time: the filter's date family. */ +const TIME_SORT_TYPES: ReadonlySet = new Set(FILTER_DATE_LIKE_TYPES) +/** Ordered by size: the spec's numeric value family, and `boolean` (false < true). */ +const SIZE_SORT_TYPES: ReadonlySet = new Set([...FILTER_NUMBER_LIKE_TYPES, 'boolean']) + +/** + * Which words name a sort direction on a field of `type`. The one source for + * every surface that words a direction — the sort builder's levels and the + * list's sort chip — so a number never reads "A → Z" in one and "Low → High" + * in the other. An unknown or absent type reads as the alphabet. + */ +export function sortWording(type: string | undefined): SortWording { + if (type && TIME_SORT_TYPES.has(type)) return 'time' + if (type && SIZE_SORT_TYPES.has(type)) return 'size' + return 'alphabet' +} + +/** The words for one sort direction on a field of `type`: time, size or the alphabet. */ +export function sortDirectionLabel( + type: string | undefined, + order: 'asc' | 'desc', + t: (key: string) => string, +): string { + // Literal keys, not a template: the locale gates read keys by their text. + switch (sortWording(type)) { + case 'time': + return order === 'asc' ? t('listConditions.sort.time_asc') : t('listConditions.sort.time_desc') + case 'size': + return order === 'asc' ? t('listConditions.sort.size_asc') : t('listConditions.sort.size_desc') + default: + return order === 'asc' ? t('listConditions.sort.alphabet_asc') : t('listConditions.sort.alphabet_desc') + } +} /** * One row of the SortBuilder UI: the spec's `SortItem` (`{ field, order }`) @@ -63,9 +100,10 @@ export interface SortBuilderProps { */ disabled?: boolean /** - * The field's type (objectstack#27520). A `date` or `datetime` row names - * its direction as time ("Oldest → Newest") instead of "A → Z". Absent, - * the row reads "A → Z" as before. + * The field's type (objectstack#27520). A date-like row names its + * direction as time ("Oldest → Newest"), a numeric or boolean row as size + * ("Low → High"), anything else as the alphabet ("A → Z"); see + * {@link sortWording}. Absent, the row reads "A → Z". */ type?: string }>; @@ -124,12 +162,12 @@ export function SortBuilder({ // already sorts by is not offered again. const firstChoosable = fields.find((f) => !f.disabled && !heldBy.has(f.value)); - // A date's direction is time, not the alphabet (objectstack#27520). + // A date's direction is time and a number's is size, not the alphabet. const typeOf = new Map(fields.map((f) => [f.value, f.type])); - const directionLabels = (field: string) => - DATE_SORT_TYPES.has(typeOf.get(field) ?? '') - ? { asc: t('sortBuilder.oldestFirst'), desc: t('sortBuilder.newestFirst') } - : { asc: t('sortBuilder.ascending'), desc: t('sortBuilder.descending') }; + const directionLabels = (field: string) => ({ + asc: sortDirectionLabel(typeOf.get(field), 'asc', t), + desc: sortDirectionLabel(typeOf.get(field), 'desc', t), + }); const addItem = () => { const newItem: SortItem = { diff --git a/ui/packages/plugin-list/src/conditions/ListConditionControls.tsx b/ui/packages/plugin-list/src/conditions/ListConditionControls.tsx index 6bc56cca37f..c454953b494 100644 --- a/ui/packages/plugin-list/src/conditions/ListConditionControls.tsx +++ b/ui/packages/plugin-list/src/conditions/ListConditionControls.tsx @@ -59,7 +59,6 @@ import { relationPathOf, removeCondition, seedValueFor, - sortWording, upsertCondition, type ConditionField, type ViewConditionChip, @@ -360,18 +359,6 @@ export function useLookupValueNames( ); } -/** The words for one sort direction on a field of `type`: time, size or the alphabet. */ -export function sortDirectionLabel(type: string | undefined, order: 'asc' | 'desc', t: Translate): string { - switch (sortWording(type)) { - case 'time': - return order === 'asc' ? t('listConditions.sort.time_asc') : t('listConditions.sort.time_desc'); - case 'size': - return order === 'asc' ? t('listConditions.sort.size_asc') : t('listConditions.sort.size_desc'); - default: - return order === 'asc' ? t('listConditions.sort.alphabet_asc') : t('listConditions.sort.alphabet_desc'); - } -} - // --------------------------------------------------------------------------- // FilterPanel // --------------------------------------------------------------------------- diff --git a/ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx b/ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx index 7bd6f561150..abe214a1125 100644 --- a/ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx +++ b/ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx @@ -20,7 +20,7 @@ import { act, fireEvent, render, screen, within } from '@testing-library/react'; import type { FilterBuilderRowGroup, SortItem } from '@object-ui/components'; import { FieldList, fieldTypeIcon, moveFieldInOrder, orderFieldList } from '../FieldList'; import { FilterValuePanel, quickDateWindowValue } from '../FilterValuePanel'; -import { ConditionChipRow, FilterPanel, SortPanel, describeConditionValue, sortDirectionLabel } from '../ListConditionControls'; +import { ConditionChipRow, FilterPanel, SortPanel, describeConditionValue } from '../ListConditionControls'; import { addSortLevel, chipsAreIndependent, @@ -35,7 +35,7 @@ import type { FilterBuilderRow } from '@object-ui/components'; import { readFileSync } from 'node:fs'; import { dirname, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; -import { operatorsForField } from '@object-ui/components'; +import { operatorsForField, sortDirectionLabel } from '@object-ui/components'; import { builtInLocales, en as enPack, zh as zhPack } from '@object-ui/i18n/locales'; import { I18nProvider } from '@object-ui/i18n'; import { parseFilterAST } from '@objectstack/spec/data'; diff --git a/ui/packages/plugin-list/src/conditions/conditionModel.ts b/ui/packages/plugin-list/src/conditions/conditionModel.ts index 02fcfbe561c..7b50684e54a 100644 --- a/ui/packages/plugin-list/src/conditions/conditionModel.ts +++ b/ui/packages/plugin-list/src/conditions/conditionModel.ts @@ -163,15 +163,6 @@ export function addSortLevel(items: readonly SortItem[], field: string, order: ' return [...items, { id, field, order }]; } -/** The direction words a sort chip uses, by field type: time, size or the alphabet. */ -export type SortWording = 'time' | 'size' | 'alphabet'; - -export function sortWording(type: string | undefined): SortWording { - if (type && DATE_TYPES.has(type)) return 'time'; - if (type && (NUMBER_TYPES.has(type) || type === 'boolean')) return 'size'; - return 'alphabet'; -} - /** One condition of the view's own filter, read for a locked chip. */ export interface ViewConditionChip { key: string; From 0d00ea278a1ceb1cb7f1f9b9548a1367738ecaf2 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 17:10:54 +0000 Subject: [PATCH 2/5] refactor(components, plugin-list): keep the sort wording module-local to SortBuilder The list's sortDirectionLabel had no non-test caller; its only live reader of these rows is SortBuilder now, so the copy and its defaults rows go. Claude-Session: https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW --- ui/packages/components/src/custom/sort-builder.tsx | 13 ++++++------- .../conditions/__tests__/listConditions.test.tsx | 9 +-------- .../src/conditions/conditionTranslations.ts | 6 ------ 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/ui/packages/components/src/custom/sort-builder.tsx b/ui/packages/components/src/custom/sort-builder.tsx index 469a1983609..0a1e0ac9ac4 100644 --- a/ui/packages/components/src/custom/sort-builder.tsx +++ b/ui/packages/components/src/custom/sort-builder.tsx @@ -35,7 +35,7 @@ const useSafeSortTranslation = createSafeTranslation( ) /** The direction words a sort level uses, by field type: time, size or the alphabet. */ -export type SortWording = 'time' | 'size' | 'alphabet' +type SortWording = 'time' | 'size' | 'alphabet' /** Ordered by time: the filter's date family. */ const TIME_SORT_TYPES: ReadonlySet = new Set(FILTER_DATE_LIKE_TYPES) @@ -43,19 +43,18 @@ const TIME_SORT_TYPES: ReadonlySet = new Set(FILTER_DATE_LIKE_TY const SIZE_SORT_TYPES: ReadonlySet = new Set([...FILTER_NUMBER_LIKE_TYPES, 'boolean']) /** - * Which words name a sort direction on a field of `type`. The one source for - * every surface that words a direction — the sort builder's levels and the - * list's sort chip — so a number never reads "A → Z" in one and "Low → High" - * in the other. An unknown or absent type reads as the alphabet. + * Which words name a sort direction on a field of `type`, over the + * `listConditions.sort.*` rows every locale carries. An unknown or absent type + * reads as the alphabet. */ -export function sortWording(type: string | undefined): SortWording { +function sortWording(type: string | undefined): SortWording { if (type && TIME_SORT_TYPES.has(type)) return 'time' if (type && SIZE_SORT_TYPES.has(type)) return 'size' return 'alphabet' } /** The words for one sort direction on a field of `type`: time, size or the alphabet. */ -export function sortDirectionLabel( +function sortDirectionLabel( type: string | undefined, order: 'asc' | 'desc', t: (key: string) => string, diff --git a/ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx b/ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx index abe214a1125..27de79e3061 100644 --- a/ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx +++ b/ui/packages/plugin-list/src/conditions/__tests__/listConditions.test.tsx @@ -35,7 +35,7 @@ import type { FilterBuilderRow } from '@object-ui/components'; import { readFileSync } from 'node:fs'; import { dirname, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; -import { operatorsForField, sortDirectionLabel } from '@object-ui/components'; +import { operatorsForField } from '@object-ui/components'; import { builtInLocales, en as enPack, zh as zhPack } from '@object-ui/i18n/locales'; import { I18nProvider } from '@object-ui/i18n'; import { parseFilterAST } from '@objectstack/spec/data'; @@ -596,13 +596,6 @@ describe('SortPanel — the same field list with the direction on top', () => { render( {}} />); expect(screen.queryByTestId('sort-panel-open-advanced')).toBeNull(); }); - - it('words the direction by type: time for dates, size for numbers, the alphabet for text', () => { - const t = (key: string) => LIST_CONDITION_DEFAULT_TRANSLATIONS[key] ?? key; - expect(sortDirectionLabel('date', 'asc', t as never)).toBe('Oldest → Newest'); - expect(sortDirectionLabel('currency', 'desc', t as never)).toBe('High → Low'); - expect(sortDirectionLabel('text', 'asc', t as never)).toBe('A → Z'); - }); }); describe('ConditionChipRow — the row under the view bar', () => { diff --git a/ui/packages/plugin-list/src/conditions/conditionTranslations.ts b/ui/packages/plugin-list/src/conditions/conditionTranslations.ts index bb3678c454a..e28107481ae 100644 --- a/ui/packages/plugin-list/src/conditions/conditionTranslations.ts +++ b/ui/packages/plugin-list/src/conditions/conditionTranslations.ts @@ -77,12 +77,6 @@ export const LIST_CONDITION_DEFAULT_TRANSLATIONS: Record = { 'listConditions.sort.direction': 'Direction', 'listConditions.sort.ascending': 'Ascending', 'listConditions.sort.descending': 'Descending', - 'listConditions.sort.time_asc': 'Oldest → Newest', - 'listConditions.sort.time_desc': 'Newest → Oldest', - 'listConditions.sort.size_asc': 'Low → High', - 'listConditions.sort.size_desc': 'High → Low', - 'listConditions.sort.alphabet_asc': 'A → Z', - 'listConditions.sort.alphabet_desc': 'Z → A', 'listConditions.chips.region': 'Sort and filter conditions', 'listConditions.chips.pattern': '{{field}}: {{value}}', 'listConditions.chips.listJoiner': ', ', From f4454bad056b96224cde7f3ed148135d841648b9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 17:11:09 +0000 Subject: [PATCH 3/5] chore: changeset for the sort builder's size wording Claude-Session: https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW --- .changeset/sort-builder-size-wording.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .changeset/sort-builder-size-wording.md diff --git a/.changeset/sort-builder-size-wording.md b/.changeset/sort-builder-size-wording.md new file mode 100644 index 00000000000..c82d0e3e1d4 --- /dev/null +++ b/.changeset/sort-builder-size-wording.md @@ -0,0 +1,11 @@ +--- +'@object-ui/components': patch +'@object-ui/plugin-list': patch +--- + +fix(components): the sort builder words a number, percent, progress or currency direction as size + +Clause-②: no +Metadata-protocol: none + +A sort level on a numeric field read "A → Z" / "Z → A" in the sort builder (the list's "All sort levels" panel), while a date read "Oldest → Newest". Numeric, percent, progress, currency, rating and boolean levels now read "Low → High" / "High → Low" (zh: 「小 → 大」 / 「大 → 小」), date, datetime and time levels read as time, and text keeps the alphabet. The words come from the `listConditions.sort.*` rows every locale already carries. From 5615c99dbc2c1389dadaf8598c48d2021c34045a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 18:39:20 +0000 Subject: [PATCH 4/5] fix(plugin-list): the phone sort sheet words a numeric level's direction as size Claude-Session: https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW --- .changeset/sort-builder-size-wording.md | 4 +- .../ListView.phonePanels-35884.test.tsx | 42 ++++++++++++++++++- .../src/conditions/conditionModel.ts | 22 ++++++++++ .../src/conditions/conditionTranslations.ts | 13 +++--- .../plugin-list/src/phone/PhoneListPanels.tsx | 11 +++-- 5 files changed, 77 insertions(+), 15 deletions(-) diff --git a/.changeset/sort-builder-size-wording.md b/.changeset/sort-builder-size-wording.md index c82d0e3e1d4..bd021c8a1f7 100644 --- a/.changeset/sort-builder-size-wording.md +++ b/.changeset/sort-builder-size-wording.md @@ -3,9 +3,9 @@ '@object-ui/plugin-list': patch --- -fix(components): the sort builder words a number, percent, progress or currency direction as size +fix(components, plugin-list): the sort builder and the phone sort sheet word a number, percent, progress or currency direction as size Clause-②: no Metadata-protocol: none -A sort level on a numeric field read "A → Z" / "Z → A" in the sort builder (the list's "All sort levels" panel), while a date read "Oldest → Newest". Numeric, percent, progress, currency, rating and boolean levels now read "Low → High" / "High → Low" (zh: 「小 → 大」 / 「大 → 小」), date, datetime and time levels read as time, and text keeps the alphabet. The words come from the `listConditions.sort.*` rows every locale already carries. +A sort level on a numeric field read "A → Z" / "Z → A" in the sort builder (the list's "All sort levels" panel) and in the phone sort sheet's levels, while a date read "Oldest → Newest". Numeric, percent, progress, currency, rating and boolean levels now read "Low → High" / "High → Low" (zh: 「小 → 大」 / 「大 → 小」), date, datetime and time levels read as time, and text keeps the alphabet, on both surfaces. The words come from the `listConditions.sort.*` rows every locale already carries. diff --git a/ui/packages/plugin-list/src/__tests__/ListView.phonePanels-35884.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.phonePanels-35884.test.tsx index 38a1069dae1..4f2511fb645 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.phonePanels-35884.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.phonePanels-35884.test.tsx @@ -57,7 +57,16 @@ function stubPhone() { }))); } -function mount(schema: Partial = {}, props: Record = {}) { +const OBJECT_FIELDS: Record = { + name: { type: 'text', label: 'Name' }, + stage: { type: 'text', label: 'Stage' }, +}; + +function mount( + schema: Partial = {}, + props: Record = {}, + objectFields: Record = OBJECT_FIELDS, +) { const dataSource = { find: vi.fn().mockResolvedValue({ data: RECORDS, total: 1 }), findOne: vi.fn(), @@ -66,7 +75,7 @@ function mount(schema: Partial = {}, props: Record { await waitFor(() => expect(handleOf(0)).toHaveFocus()); }); }); + +describe('the phone sort levels word a direction by the field\'s type', () => { + const TYPED = { + name: { type: 'text', label: 'Name' }, + due: { type: 'date', label: 'Due' }, + hours: { type: 'number', label: 'Hours' }, + progress: { type: 'progress', label: 'Progress' }, + done: { type: 'percent', label: 'Done' }, + budget: { type: 'currency', label: 'Budget' }, + }; + const directionOf = async (field: string) => { + mount({ fields: Object.keys(TYPED) }, {}, TYPED); + await screen.findByTestId('grid-stub'); + await addSortLevel(field); + return screen.getByTestId('sort-builder-row-direction').textContent; + }; + + for (const field of ['hours', 'progress', 'done', 'budget']) { + it(`a ${TYPED[field as keyof typeof TYPED].type} level reads "Low → High"`, async () => { + expect(await directionOf(field)).toContain('Low → High'); + }); + } + + it('CONTROL: a date level reads as time, a text level as the alphabet', async () => { + expect(await directionOf('due')).toContain('Oldest → Newest'); + cleanup(); + expect(await directionOf('name')).toContain('A → Z'); + }); +}); diff --git a/ui/packages/plugin-list/src/conditions/conditionModel.ts b/ui/packages/plugin-list/src/conditions/conditionModel.ts index 7b50684e54a..cf00c953bda 100644 --- a/ui/packages/plugin-list/src/conditions/conditionModel.ts +++ b/ui/packages/plugin-list/src/conditions/conditionModel.ts @@ -163,6 +163,28 @@ export function addSortLevel(items: readonly SortItem[], field: string, order: ' return [...items, { id, field, order }]; } +/** + * The words for one sort direction on a field of `type`: time for the date + * family, size for the numeric family and `boolean`, the alphabet otherwise. + * The phone sort sheet's levels read it. `SortBuilder` in + * `@object-ui/components` words its levels with the same three-way rule over + * the same `listConditions.sort.*` rows; it keeps its copy module-local + * because sharing it would add a published export to that package. + */ +export function sortDirectionLabel( + type: string | undefined, + order: 'asc' | 'desc', + t: (key: string) => string, +): string { + if (type && DATE_TYPES.has(type)) { + return order === 'asc' ? t('listConditions.sort.time_asc') : t('listConditions.sort.time_desc'); + } + if (type && (NUMBER_TYPES.has(type) || type === 'boolean')) { + return order === 'asc' ? t('listConditions.sort.size_asc') : t('listConditions.sort.size_desc'); + } + return order === 'asc' ? t('listConditions.sort.alphabet_asc') : t('listConditions.sort.alphabet_desc'); +} + /** One condition of the view's own filter, read for a locked chip. */ export interface ViewConditionChip { key: string; diff --git a/ui/packages/plugin-list/src/conditions/conditionTranslations.ts b/ui/packages/plugin-list/src/conditions/conditionTranslations.ts index e28107481ae..230cdecd2b3 100644 --- a/ui/packages/plugin-list/src/conditions/conditionTranslations.ts +++ b/ui/packages/plugin-list/src/conditions/conditionTranslations.ts @@ -77,6 +77,12 @@ export const LIST_CONDITION_DEFAULT_TRANSLATIONS: Record = { 'listConditions.sort.direction': 'Direction', 'listConditions.sort.ascending': 'Ascending', 'listConditions.sort.descending': 'Descending', + 'listConditions.sort.time_asc': 'Oldest → Newest', + 'listConditions.sort.time_desc': 'Newest → Oldest', + 'listConditions.sort.size_asc': 'Low → High', + 'listConditions.sort.size_desc': 'High → Low', + 'listConditions.sort.alphabet_asc': 'A → Z', + 'listConditions.sort.alphabet_desc': 'Z → A', 'listConditions.chips.region': 'Sort and filter conditions', 'listConditions.chips.pattern': '{{field}}: {{value}}', 'listConditions.chips.listJoiner': ', ', @@ -98,12 +104,9 @@ export const LIST_CONDITION_DEFAULT_TRANSLATIONS: Record = { 'dashboard.filters.range.this_week': 'This week', 'dashboard.filters.range.this_month': 'This month', 'dashboard.filters.range.last_30_days': 'Last 30 days', - // The phone sort sheet's level (objectstack#35884), in SortBuilder's words. + // The phone sort sheet's level (objectstack#35884), in SortBuilder's words; + // its direction reads the `listConditions.sort.*` rows above. 'sortBuilder.addSort': 'Add sort', - 'sortBuilder.ascending': 'A → Z', - 'sortBuilder.descending': 'Z → A', - 'sortBuilder.oldestFirst': 'Oldest → Newest', - 'sortBuilder.newestFirst': 'Newest → Oldest', 'sortBuilder.reorder': 'Drag to reorder', 'sortBuilder.removeSort': 'Remove sort', 'sortBuilder.levelOptions': 'Options for {{label}}', diff --git a/ui/packages/plugin-list/src/phone/PhoneListPanels.tsx b/ui/packages/plugin-list/src/phone/PhoneListPanels.tsx index 28abfd80bf0..21f2cbfa7df 100644 --- a/ui/packages/plugin-list/src/phone/PhoneListPanels.tsx +++ b/ui/packages/plugin-list/src/phone/PhoneListPanels.tsx @@ -52,7 +52,7 @@ import { ArrowUpDown, Check, ChevronLeft, GripVertical, Info, ListFilter, MoreHo import { FieldList } from '../conditions/FieldList'; import { isQuickRowApplied } from '../conditions/FilterValuePanel'; import { FilterPanel, SortPanel, describeConditionValue, useLookupValueNames } from '../conditions/ListConditionControls'; -import { chipsAreIndependent, removeCondition, type ConditionField } from '../conditions/conditionModel'; +import { chipsAreIndependent, removeCondition, sortDirectionLabel, type ConditionField } from '../conditions/conditionModel'; import { useListConditionTranslation } from '../conditions/conditionTranslations'; // --------------------------------------------------------------------------- @@ -315,8 +315,6 @@ function useStaged(open: boolean, value: T, firstStep: S): [T, React.Dispa // Sort // --------------------------------------------------------------------------- -const DATE_SORT_TYPES = new Set(['date', 'datetime']); - /** * The phone sort sheet's levels (objectstack#35884): each level on two lines, * the field over its direction, with a handle a finger drags (pointer events: @@ -357,9 +355,10 @@ function PhoneSortLevels({ fields, value, onChange, onChangeField }: { {value.map((item, index) => { const field = fields.find((f) => f.value === item.field); const label = field?.label ?? item.field; - const direction = DATE_SORT_TYPES.has(field?.type ?? '') - ? { asc: t('sortBuilder.oldestFirst'), desc: t('sortBuilder.newestFirst') } - : { asc: t('sortBuilder.ascending'), desc: t('sortBuilder.descending') }; + const direction = { + asc: sortDirectionLabel(field?.type, 'asc', t), + desc: sortDirectionLabel(field?.type, 'desc', t), + }; return (
Date: Tue, 24 Nov 2026 20:44:33 +0000 Subject: [PATCH 5/5] fix(i18n, components, plugin-list): the Arabic alphabet sort pair reads left to right; pin the pack wording Claude-Session: https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW --- .changeset/sort-builder-size-wording.md | 7 +++ ...r-date-direction-duplicates-27520.test.tsx | 43 ++++++++++++++++++- .../components/src/custom/sort-builder.tsx | 5 +++ ui/packages/i18n/src/locales/ar.ts | 4 +- .../ListView.phonePanels-35884.test.tsx | 10 +++++ .../src/conditions/conditionModel.ts | 11 +++-- 6 files changed, 72 insertions(+), 8 deletions(-) diff --git a/.changeset/sort-builder-size-wording.md b/.changeset/sort-builder-size-wording.md index bd021c8a1f7..74edf64dad5 100644 --- a/.changeset/sort-builder-size-wording.md +++ b/.changeset/sort-builder-size-wording.md @@ -1,6 +1,7 @@ --- '@object-ui/components': patch '@object-ui/plugin-list': patch +'@object-ui/i18n': patch --- fix(components, plugin-list): the sort builder and the phone sort sheet word a number, percent, progress or currency direction as size @@ -9,3 +10,9 @@ Clause-②: no Metadata-protocol: none A sort level on a numeric field read "A → Z" / "Z → A" in the sort builder (the list's "All sort levels" panel) and in the phone sort sheet's levels, while a date read "Oldest → Newest". Numeric, percent, progress, currency, rating and boolean levels now read "Low → High" / "High → Low" (zh: 「小 → 大」 / 「大 → 小」), date, datetime and time levels read as time, and text keeps the alphabet, on both surfaces. The words come from the `listConditions.sort.*` rows every locale already carries. + +What else a reader sees change: + +- The four `sortBuilder.ascending`, `sortBuilder.descending`, `sortBuilder.oldestFirst` and `sortBuilder.newestFirst` rows are no longer read by either surface; the rows stay in the packs. A host that overrode them to reword a sort direction now overrides `listConditions.sort.alphabet_asc` / `alphabet_desc` / `time_asc` / `time_desc` (and `size_asc` / `size_desc` for numbers) instead. +- Because the words now come from `listConditions.sort.*`, the date and text wording changes in some locales: Japanese and Korean dates read 「古い → 新しい」 / 「오래된 순 → 최신 순」 instead of 「古い順」 / 「오래된 순」, Russian dates read "Старые → Новые" instead of "Сначала старые", and Russian text reads "А → Я" instead of "A → Z". +- Arabic: the `listConditions.sort.alphabet_asc` / `alphabet_desc` pair now reads "A → Z" / "Z → A". A run of two Latin letters stays left to right on a right-to-left page, so the old "A ← Z" showed ascending as Z to A. diff --git a/ui/packages/components/src/__tests__/sort-builder-date-direction-duplicates-27520.test.tsx b/ui/packages/components/src/__tests__/sort-builder-date-direction-duplicates-27520.test.tsx index 895451b986a..62f431d286f 100644 --- a/ui/packages/components/src/__tests__/sort-builder-date-direction-duplicates-27520.test.tsx +++ b/ui/packages/components/src/__tests__/sort-builder-date-direction-duplicates-27520.test.tsx @@ -21,8 +21,9 @@ */ import { describe, it, expect, vi, afterEach } from 'vitest'; import React from 'react'; -import { cleanup, render, screen, fireEvent, within } from '@testing-library/react'; +import { cleanup, render, screen, fireEvent, within, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom'; +import { I18nProvider } from '@object-ui/i18n'; import { SortBuilder, type SortBuilderProps, type SortItem } from '../custom/sort-builder'; type Fields = NonNullable; @@ -140,7 +141,7 @@ describe('SortBuilder keeps one row per field (objectstack#27520 row 7)', () => }); }); -describe('SortBuilder names a numeric sort as size, from the chip\'s own table', () => { +describe('SortBuilder words a direction by the field\'s type: size, time or the alphabet', () => { const NUMERIC: Fields = [ { value: 'title', label: 'Title', type: 'text' }, { value: 'due_date', label: 'Due Date', type: 'date' }, @@ -148,6 +149,8 @@ describe('SortBuilder names a numeric sort as size, from the chip\'s own table', { value: 'progress', label: 'Progress', type: 'progress' }, { value: 'completion', label: 'Completion', type: 'percent' }, { value: 'budget', label: 'Budget', type: 'currency' }, + { value: 'active', label: 'Active', type: 'boolean' }, + { value: 'starts_at', label: 'Starts At', type: 'time' }, ]; const optionLabels = (i: number) => optionsOf(directionTriggers()[i]).map((o) => o.label); @@ -157,9 +160,45 @@ describe('SortBuilder names a numeric sort as size, from the chip\'s own table', expect(directionTriggers()[3]).toHaveTextContent('High → Low'); }); + it('a boolean row reads as size and a time row as time', () => { + mount([asc('active'), asc('starts_at')], NUMERIC); + expect(optionLabels(0)).toEqual(['Low → High', 'High → Low']); + expect(optionLabels(1)).toEqual(['Oldest → Newest', 'Newest → Oldest']); + }); + it('CONTROL: beside them a date keeps time and text keeps the alphabet', () => { mount([asc('due_date'), asc('title'), asc('estimate_hours')], NUMERIC); expect(optionLabels(0)).toEqual(['Oldest → Newest', 'Newest → Oldest']); expect(optionLabels(1)).toEqual(['A → Z', 'Z → A']); }); }); + +describe('SortBuilder reads its direction words from the locale pack', () => { + const PACK_FIELDS: Fields = [ + { value: 'title', label: 'Title', type: 'text' }, + { value: 'estimate_hours', label: 'Estimate', type: 'number' }, + { value: 'progress', label: 'Progress', type: 'progress' }, + ]; + const inLanguage = (language: string, initial: Row[]) => + render( + + {}} /> + , + ); + const labelsAt = (i: number) => optionsOf(directionTriggers()[i]).map((o) => o.label); + + it('zh: a number and a progress row read 「小 → 大」 / 「大 → 小」', async () => { + inLanguage('zh', [asc('estimate_hours'), asc('progress')]); + await waitFor(() => expect(directionTriggers()[0]).toHaveTextContent('小 → 大')); + expect(labelsAt(0)).toEqual(['小 → 大', '大 → 小']); + expect(labelsAt(1)).toEqual(['小 → 大', '大 → 小']); + }); + + it('ar: a text row reads the Latin pair left to right, "A → Z" / "Z → A"', async () => { + inLanguage('ar', [asc('title'), asc('estimate_hours')]); + // The Arabic pack is in once the number row reads in Arabic; only then is + // the text row's pair the pack's and not the built-in English default. + await waitFor(() => expect(directionTriggers()[1]).toHaveTextContent('الأصغر ← الأكبر')); + expect(labelsAt(0)).toEqual(['A → Z', 'Z → A']); + }); +}); diff --git a/ui/packages/components/src/custom/sort-builder.tsx b/ui/packages/components/src/custom/sort-builder.tsx index 0a1e0ac9ac4..4d6b8ac7e05 100644 --- a/ui/packages/components/src/custom/sort-builder.tsx +++ b/ui/packages/components/src/custom/sort-builder.tsx @@ -46,6 +46,11 @@ const SIZE_SORT_TYPES: ReadonlySet = new Set([...FILTER_NUMBER_L * Which words name a sort direction on a field of `type`, over the * `listConditions.sort.*` rows every locale carries. An unknown or absent type * reads as the alphabet. + * + * Twin: `sortDirectionLabel` in `ui/packages/plugin-list/src/conditions/conditionModel.ts` + * words the phone sort sheet's levels by the same rule over the same rows. It + * is a copy, not an import, because sharing it would add a published export + * to this package; change both together. */ function sortWording(type: string | undefined): SortWording { if (type && TIME_SORT_TYPES.has(type)) return 'time' diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index f636ff5cbf3..eb6be4c4151 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -6102,8 +6102,8 @@ const ar = { time_desc: 'الأحدث ← الأقدم', size_asc: 'الأصغر ← الأكبر', size_desc: 'الأكبر ← الأصغر', - alphabet_asc: 'A ← Z', - alphabet_desc: 'Z ← A', + alphabet_asc: 'A → Z', + alphabet_desc: 'Z → A', }, chips: { region: 'شروط الفرز والتصفية', diff --git a/ui/packages/plugin-list/src/__tests__/ListView.phonePanels-35884.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.phonePanels-35884.test.tsx index 4f2511fb645..8f98c6fb4b6 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.phonePanels-35884.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.phonePanels-35884.test.tsx @@ -344,6 +344,8 @@ describe('the phone sort levels word a direction by the field\'s type', () => { progress: { type: 'progress', label: 'Progress' }, done: { type: 'percent', label: 'Done' }, budget: { type: 'currency', label: 'Budget' }, + active: { type: 'boolean', label: 'Active' }, + starts: { type: 'time', label: 'Starts' }, }; const directionOf = async (field: string) => { mount({ fields: Object.keys(TYPED) }, {}, TYPED); @@ -358,6 +360,14 @@ describe('the phone sort levels word a direction by the field\'s type', () => { }); } + it('a boolean level reads as size', async () => { + expect(await directionOf('active')).toContain('Low → High'); + }); + + it('a time level reads as time', async () => { + expect(await directionOf('starts')).toContain('Oldest → Newest'); + }); + it('CONTROL: a date level reads as time, a text level as the alphabet', async () => { expect(await directionOf('due')).toContain('Oldest → Newest'); cleanup(); diff --git a/ui/packages/plugin-list/src/conditions/conditionModel.ts b/ui/packages/plugin-list/src/conditions/conditionModel.ts index cf00c953bda..0050808b290 100644 --- a/ui/packages/plugin-list/src/conditions/conditionModel.ts +++ b/ui/packages/plugin-list/src/conditions/conditionModel.ts @@ -166,10 +166,13 @@ export function addSortLevel(items: readonly SortItem[], field: string, order: ' /** * The words for one sort direction on a field of `type`: time for the date * family, size for the numeric family and `boolean`, the alphabet otherwise. - * The phone sort sheet's levels read it. `SortBuilder` in - * `@object-ui/components` words its levels with the same three-way rule over - * the same `listConditions.sort.*` rows; it keeps its copy module-local - * because sharing it would add a published export to that package. + * The phone sort sheet's levels read it. + * + * Twin: `sortWording` / `sortDirectionLabel` in + * `ui/packages/components/src/custom/sort-builder.tsx` word `SortBuilder`'s + * levels by the same three-way rule over the same `listConditions.sort.*` + * rows. That copy stays module-local because sharing it would add a published + * export to `@object-ui/components`; change both together. */ export function sortDirectionLabel( type: string | undefined,