fix(core): Card's collapse toggle now respects defaultCollapsed, and works without a title - #490
Open
dvcolomban wants to merge 2 commits into
Open
fix(core): Card's collapse toggle now respects defaultCollapsed, and works without a title#490dvcolomban wants to merge 2 commits into
dvcolomban wants to merge 2 commits into
Conversation
@vitejs/devtools
@vitejs/devtools-kit
@vitejs/devtools-oxc
@vitejs/devtools-rolldown
@vitejs/devtools-vite
@vitejs/devtools-vitest
commit: |
dvcolomban
force-pushed
the
fix/json-render-card-collapse
branch
from
July 28, 2026 17:02
7a6dbc0 to
a7846d1
Compare
…works without a title
`defaultCollapsed` was declared in the schema but never read — collapse
state was a hardcoded `ref(false)`, so a Card always rendered expanded on
first paint regardless of the prop. It's now seeded from `defaultCollapsed`.
Also: a collapsible Card without a `title` had no header to click at all
(the header only rendered when `title` was truthy) — it now renders
whenever either is set.
Toggling now emits a `toggle` event, so a spec can react via `on: { toggle: ... }`.
Also types Card's own props (`CardProps`) co-located in `Card.ts` itself,
and adds `registryProps<Type, Props>()` — a typed alternative to the
untyped `props: ['element', 'emit', ...]` array form every registry
component currently uses, so `defineComponent` infers `setup`'s
`ctx.element.props` as the component's own type instead of `Record<string,
any>`. `CardProps` is re-exported from the client webcomponents entry
(`@vitejs/devtools/client/webcomponents`, already public) as an opt-in
strict type.
dvcolomban
force-pushed
the
fix/json-render-card-collapse
branch
from
July 28, 2026 17:14
a7846d1 to
7632c22
Compare
dvcolomban
marked this pull request as ready for review
July 28, 2026 17:21
…d-collapse # Conflicts: # packages/core/src/client/webcomponents/index.ts # packages/core/src/client/webcomponents/json-render/registry.ts # test/__snapshots__/tsnapi/@vitejs/devtools/client/webcomponents.snapshot.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Card's collapse state was fully local and disconnected from its own props:defaultCollapsedwas declared in the base catalog but never read — collapse state was hardcoded toref(false), so authoring{ defaultCollapsed: true }had no effect.collapsible: truewithout atitlerendered no header at all, so a titleless collapsible card had no chevron and could never be toggled.defaultCollapsed, and the header (with chevron) renders whenevertitle || collapsible.toggleevent is emitted on collapse/expand so specs can wireon: { toggle: ... }.$bindState-controlled variant (mirroringSwitch/TextInput) but dropped it — plain local state is enough for what collapse actually needs, and double-binding a UI affordance like this was overkill.Screenshots
Test plan
pnpm run lintpnpm run typecheckCardstory Controls: toggledcollapsible/defaultCollapsed, confirmed initial state and click-to-toggle both work, including with notitle