Skip to content

Commit 829a45e

Browse files
fix(plugin-kanban): a collapsed lane CJK title stands upright instead of turned 180 degrees (#37316)
Fixes #37274 Clause-②: no Metadata-protocol: none ## 维护者速读 - 中文、日文、韩文用户在看板上看到的折叠列(例如没有卡片的「已取消」)列名,从之前每个字倒立、读不出,变为每个字立着、从上往下竖排;英文列名照旧。 - 修的是用户截图报来的问题:订单看板的折叠列在中文界面下读不出是哪一列。 - 出错的话只是折叠列标题显示方式不对,不影响展开、拖拽和数据;改动只在一处样式,可直接撤回。 - 无。 ## What changes A collapsed kanban lane draws its title down a narrow spine. It was `writing-mode: vertical-rl` plus a 180° turn (`rotate-180`). vertical-rl already sets Han, kana and Hangul glyphs upright, so the extra turn stood every CJK glyph on its head and the title read bottom to top. The issue described the glyphs as lying sideways; measured in Chromium they are upside down (180°), the same root cause. `ui/packages/plugin-kanban/src/KanbanImpl.tsx` gains `collapsedTitleClass(title)`: - a title that contains Han, Hiragana, Katakana or Hangul (`\p{Script=…}`) renders `[writing-mode:vertical-rl] [text-orientation:upright]`, no turn: every glyph upright, top to bottom; - any other title keeps today's `[writing-mode:vertical-rl] rotate-180` byte for byte (the CONTROL). Why `upright` for the CJK arm and not simply dropping `rotate-180` for every title (`text-orientation: mixed`): dropping the turn for all titles would flip a Latin title from bottom-to-top to top-to-bottom, which breaks the CONTROL. `upright` also keeps a mixed title such as 「Q3 已取消」 in one readable column instead of turning its Latin run sideways. The swimlane collapsed header (the row header near the swimlane loop) was checked as the triage asked: it is a horizontal row with no vertical writing mode, so it does not have this defect shape and is unchanged. The swimlane layout's column title row uses the same `LaneHeading`, so it gets the fix too. ## Tests - New pin `ui/packages/plugin-kanban/src/__tests__/collapsedTitleCjkUpright-37274.test.tsx`: a collapsed 「已取消」 lane carries `[writing-mode:vertical-rl]` + `[text-orientation:upright]` and no `rotate-180`; a collapsed `Cancelled` lane (CONTROL) keeps `[writing-mode:vertical-rl]` + `rotate-180`. jsdom lays nothing out, so the pin reads the classes that decide orientation. - Red without the fix (`KanbanImpl.tsx` restored from `origin/main` 4fb03eb, then put back from HEAD, `git diff HEAD` empty and blob hash matched): 1 failed, `expect(element).toHaveClass("[writing-mode:vertical-rl] [text-orientation:upright]")`. - Green with it: 1 passed. - Whole package at 363a53c: `type-check` exit 0, `vitest run packages/plugin-kanban/` Test Files 88 passed (88), Tests 576 passed (576). ## Acceptance notes - Rendered in Chromium (Unifont, the container's only CJK font with vertical metrics): old rule = 「已取消」 upside down, reading bottom to top; new rule = upright, top to bottom; Latin `CANCELLED` under the old rule reads bottom to top and is unchanged by this PR. - The detection is per title, not per locale: a Latin title in a zh-CN console keeps the turn, a CJK title in an en console stands upright. ## Verification Two-minute check: open any kanban in a zh-CN console with an empty lane that auto-collapses (or a lane authored `collapsed: true` titled 「已取消」). Expected: the spine shows 已 / 取 / 消 upright, top to bottom; an English collapsed lane still reads bottom to top. Read first: `ui/packages/plugin-kanban/src/KanbanImpl.tsx` (the `collapsedTitleClass` hunk, the only behaviour change), then the pin. Derived gate families at 363a53c (`dispatch-gates.mjs --commands`): 38 derived, 38 run locally, all exit 0 (`check:type-check-debt` first run exited 3, its output not retained; the re-run waited 274s on the shared verify lock and exited 0). `--ran` reconciliation: 38 accounted, 0 NOT-MEASURED. `test:repo` and the full CI farm are left to CI. --- _Generated by [Claude Code](https://claude.ai/code/session_012MmDsSBHy5paNUz6zke9Re)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6210a08 commit 829a45e

3 files changed

Lines changed: 90 additions & 1 deletion

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/plugin-kanban': patch
3+
---
4+
5+
fix(plugin-kanban): a collapsed lane's Chinese, Japanese or Korean title reads upright, top to bottom
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A collapsed kanban lane draws its title down a narrow spine. The title was set vertical and then turned 180°, which reads well for a Latin title (bottom to top, like a book spine) but stood every Chinese, Japanese or Korean character on its head, so a lane such as 「已取消」 could not be read. A title that contains Han, kana or Hangul now drops the turn and sets every character upright, reading top to bottom; a title in Latin script renders as before.

‎ui/packages/plugin-kanban/src/KanbanImpl.tsx‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,26 @@ function laneBox(
644644
: { className: columnWidthClasses(columnStyle), style: columnStyle }
645645
}
646646

647+
/** Han, kana and Hangul: scripts whose glyphs stand upright in vertical text. */
648+
const UPRIGHT_SCRIPT = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u
649+
650+
/**
651+
* How a COLLAPSED lane's title runs down its narrow spine.
652+
*
653+
* A Latin title reads bottom-to-top, the book-spine convention: vertical-rl
654+
* lays it top-to-bottom and the 180° turn flips it. That same turn stands
655+
* every CJK glyph on its head — vertical-rl already sets Han, kana and Hangul
656+
* upright, so the rotation is what made 「已取消」 unreadable. A title in one of
657+
* those scripts drops the turn and sets EVERY glyph upright
658+
* (`text-orientation: upright`), so a mixed title such as 「Q3 已取消」 runs
659+
* down the spine as one column instead of turning its Latin run sideways.
660+
*/
661+
function collapsedTitleClass(title: string): string {
662+
return UPRIGHT_SCRIPT.test(title)
663+
? "[writing-mode:vertical-rl] [text-orientation:upright]"
664+
: "[writing-mode:vertical-rl] rotate-180"
665+
}
666+
647667
/**
648668
* The lane heading, as a disclosure when the lane declared `collapsed`
649669
* (objectui#9628).
@@ -704,7 +724,7 @@ function LaneHeading({
704724
>
705725
▶
706726
</span>
707-
<span className={cn("truncate", collapsed && "[writing-mode:vertical-rl] rotate-180")}>
727+
<span className={cn("truncate", collapsed && collapsedTitleClass(column.title))}>
708728
{column.title}
709729
</span>
710730
</button>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* A collapsed lane's CJK title stands upright — objectstack#37274.
11+
*
12+
* The defect: a collapsed lane set its title `writing-mode: vertical-rl` and
13+
* then turned it 180°. vertical-rl already sets Han, kana and Hangul upright,
14+
* so the turn stood every glyph of 「已取消」 on its head, read bottom-to-top.
15+
* A title in those scripts now drops the turn and sets every glyph upright.
16+
*
17+
* CONTROL: a Latin title keeps the turn — it still reads bottom-to-top, as it
18+
* did before this card. jsdom lays nothing out, so the pin reads the classes
19+
* that decide the orientation; the rendered orientation was measured in
20+
* Chromium on the PR.
21+
*/
22+
23+
import '@testing-library/jest-dom/vitest'
24+
import * as React from 'react'
25+
import { afterEach, describe, expect, it } from 'vitest'
26+
import { cleanup, render, screen } from '@testing-library/react'
27+
import KanbanBoard from '../KanbanImpl'
28+
import type { KanbanColumn } from '../types'
29+
30+
const COLUMNS: KanbanColumn[] = [
31+
{ id: 'open', title: 'Open', cards: [{ id: 'c1', title: 'A card' }] },
32+
{ id: 'cancelled_zh', title: '已取消', collapsed: true, cards: [] },
33+
{ id: 'cancelled_en', title: 'Cancelled', collapsed: true, cards: [] },
34+
]
35+
36+
/** The span that carries the collapsed lane's title text. */
37+
const titleSpan = (title: string) => screen.getByText(title, { selector: 'span' })
38+
39+
describe('a collapsed lane title runs down its spine readably (objectstack#37274)', () => {
40+
afterEach(cleanup)
41+
42+
it('sets a CJK title upright, without the 180° turn; a Latin title keeps the turn', () => {
43+
render(<KanbanBoard columns={COLUMNS} onCardMove={() => {}} />)
44+
45+
// Both lanes really render collapsed — a disclosure reporting closed.
46+
expect(screen.getByRole('button', { name: '已取消' })).toHaveAttribute('aria-expanded', 'false')
47+
expect(screen.getByRole('button', { name: 'Cancelled' })).toHaveAttribute('aria-expanded', 'false')
48+
49+
// THE SUBJECT — the CJK title: vertical, upright, not turned.
50+
const cjk = titleSpan('已取消')
51+
expect(cjk).toHaveClass('[writing-mode:vertical-rl]', '[text-orientation:upright]')
52+
expect(cjk).not.toHaveClass('rotate-180')
53+
54+
// CONTROL — the Latin title renders exactly as before: vertical, turned.
55+
const latin = titleSpan('Cancelled')
56+
expect(latin).toHaveClass('[writing-mode:vertical-rl]', 'rotate-180')
57+
expect(latin).not.toHaveClass('[text-orientation:upright]')
58+
})
59+
})

0 commit comments

Comments
 (0)