You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Input**: Feature specification from `/specs/001-fix-subtitle-layout-bug/spec.md`
5
+
6
+
**Note**: This template is filled in by the `/speckit.plan` command. See `.specify/templates/commands/plan.md` for the execution workflow.
7
+
8
+
## Summary
9
+
10
+
This plan addresses a layout bug in the Title component where rendering a chart with only a subtitle (and no main title) causes a layout error. The fix involves ensuring the `Title` component in `vchart` correctly handles the absence of the `text` property when interacting with `@visactor/vrender-components`.
11
+
12
+
## Technical Context
13
+
14
+
**Language/Version**: TypeScript 4.x
15
+
**Primary Dependencies**:
16
+
-`@visactor/vrender-components`: Provides the underlying Title component.
17
+
-`@visactor/vutils`: Utility functions.
18
+
**Storage**: N/A
19
+
**Testing**: Jest for unit testing.
20
+
**Target Platform**: All VChart supported platforms (Web, Mini Program, etc.)
The user reported a layout error when only `subtext` is set in the Title component.
6
+
Investigation of `packages/vchart/src/component/title/title.ts` reveals that `text` attribute is passed directly from spec:
7
+
```typescript
8
+
text: this._spec.text,
9
+
```
10
+
If `this._spec.text` is undefined, it is passed as undefined to `@visactor/vrender-components`.
11
+
12
+
## Hypothesis
13
+
14
+
The underlying `Title` component from `@visactor/vrender-components` likely expects `text` to be a valid string or handles `undefined``text` incorrectly when `subtext` is present, leading to a layout calculation failure (e.g., trying to measure undefined text).
15
+
16
+
## Proposed Solution
17
+
18
+
Ensure `text` is always a string, defaulting to `''` if undefined.
19
+
```typescript
20
+
text: this._spec.text??'',
21
+
```
22
+
23
+
## Verification
24
+
25
+
A regression test `repro.test.ts` was created to simulate the scenario.
0 commit comments