Skip to content

feat(json-render-ui): session-persist uncontrolled state and scroll position - #224

Closed
antfubot wants to merge 1 commit into
mainfrom
feat/json-render-ui-session-persist-uncontrolled
Closed

feat(json-render-ui): session-persist uncontrolled state and scroll position#224
antfubot wants to merge 1 commit into
mainfrom
feat/json-render-ui-session-persist-uncontrolled

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Why

A json-render dock lost the active spec tab / selected option / scroll position on every reload (dev-server restart, an HMR full-reload, etc.) — annoying mid-debugging. Switch/TextInput also had no working uncontrolled fallback at all (useBoundProp's setter is a no-op without a $bindState binding), so an unbound value silently didn't respond to interaction.

What changed

  • Tabs/Select/Switch/TextInput's uncontrolled fallback (used when a spec element has no $bindState binding) is now sessionStorage-backed via a new useUncontrolledValue composable, keyed by the current dock (a new DOCK_ENTRY_ID_KEY provide()d by JsonRenderView) plus a caller-supplied signature of the element's own static props.
  • Switch/TextInput gain the controlled/uncontrolled split Tabs/Select already had, so an unbound value now actually works (and persists).
  • JsonRenderView restores/persists its own scroll position per dock the same way.

Context

Ports the json-render half of vitejs/devtools#527 ("session-scoped dock UI state — restore open/selected dock, tab, and scroll across reloads") by @dvcolomban, adapted to this repo's split json-render package:

  • webcomponents/components/views/ViewJsonRender.vuepackages/json-render-ui/src/renderer.ts (JsonRenderView)
  • webcomponents/json-render/components/{Select,Switch,Tabs,TextInput}.tspackages/json-render-ui/src/components/{Select,Switch,Tabs,TextInput}.ts
  • webcomponents/json-render/composables/{dock-entry-id,useUncontrolledValue}.ts → new packages/json-render-ui/src/composables/

Upstream's registry components receive a ctx.element carrying an id; this package's BaseComponentProps (from @json-render/vue) carries only props/children/emit/on/bindings, with no element identity — useUncontrolledValue here derives its key from a caller-supplied (kind, signature) pair (the component name + its own static props) instead.

The dock-selection half (selectedId persisted on the panel store) is split out to a separate PR against packages/hub-ui, since the two are independent file sets: #223.

Part of #213 (closes once the companion hub-ui PR also merges).


Created with the help of an agent.

…osition

`Tabs`/`Select`/`Switch`/`TextInput` fall back to a local, uncontrolled
value when a spec element has no `$bindState` binding on it — that
fallback used to be lost on every reload (and, for `Switch`/`TextInput`,
didn't exist at all: an unbound `value` had no working fallback since
`useBoundProp`'s setter is a no-op without a binding). `useSessionStorage`
now backs all four, keyed by the current dock (via a new
`DOCK_ENTRY_ID_KEY` `provide()`d by `JsonRenderView`) plus a signature of
the element's own static props, so it survives a reload without bleeding
into a different element of the same kind.

`JsonRenderView` also restores/persists its own scroll position per dock,
the same way.

Context: ports vitejs/devtools#527's `sessionStorage`-keyed uncontrolled-
value and scroll restoration to this package's registry component shape
(no `ctx.element` here, so the key is a caller-supplied signature instead
of an element id).

Co-authored-by: dvcolomban <90617742+dvcolomban@users.noreply.github.com>
@netlify

netlify Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit ff314de
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a7eb2aabb12ce000868c4a6
😎 Deploy Preview https://deploy-preview-224--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants