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
{{ message }}
Repository navigation
Group components: content written in another component can't read its Vue data #169
A group component that moves its items' content somewhere else (Citry UI's CTabs places each CTab's content in its own tab panels) can't show content that reads Vue data when the items are written in a different component than the group:
<c-CTabs>
<c-TabLabels />
</c-CTabs>
If TabLabels writes <c-CTab> items whose content reads its Vue data (v-text="label"), rendering fails. Python values in the same content work.
Why
Vue keeps a slot's scope by passing the slot down the tree as a function. Here CTabs sits above TabLabels, so TabLabels never creates the component that renders its content and can't hand that function over. Citry can only copy the content into the receiving template, where Vue data would point at the wrong component, so it rejects it.
What to explore
Let the item's author register a render function with the group through provide/inject, or render the content in place and move it (Teleport-like).
Keep the server HTML and the first browser render matching.
Decide whether the limit should stay and be documented better instead.
To review later.
The problem in one paragraph
Vue data reaches content through Vue's slots, which follow where the content is written. CTabs relocates where its items' content is rendered on the server side, so by the time Vue handles the slot, what was written inside <c-CTab value="one"> in TabLabels sits somewhere completely different (inside CTabs' own template), and TabLabels' Vue data never reaches it.
Idea to explore
This should ideally still work. One direction: mark the Citry-side slots that a component like CTabs relocates, so the moved content can be connected back to the Vue slot of the component that wrote it (and therefore to that component's Vue data). Not explored yet.
note - also consider this angle - maybe instead of allowing for Citry and Vue slots to get disconnected, we could add proper support for teleports and do it with them.
Parked for after 0.7.0 (effort is medium to hard). This is the design worked out so far, kept here so the work can resume from it.
#169: content written in another component can't read its Vue data
Status: exploration note for the maintainer. No code written. Read on
origin/main 492199e7d. Line numbers are from that commit.
The problem
A group component such as Citry UI's CTabs shows each item's content
somewhere other than where the item is written: each CTab stores its
default slot, and CTabs calls it again inside its own panels. When the
items are written by a different component than the one holding the
group, and their content reads that component's Vue data, rendering fails:
<!-- Page -->
<c-CTabs>
<c-TabLabels />
</c-CTabs>
<!-- TabLabels, which has js_data with `label` -->
<c-CTab value="one">
<span v-text="label"></span>
</c-CTab>
Content with only Python values works from anywhere, and items written
directly by the component that holds <c-CTabs> work too.
Prior art
How the group moves content.CTabs.template_data shares a registry
with self.provide(). Each CTab stores its default slot as a Python Slot and renders nothing in place. CTabs' template holds the items
first, then the panels, which call the stored slots again
(citry_ui/components/ctabs/ctabs.py:39-54, 235, 262-308, 794-867, 918-982). The same pattern is used by eight other Citry UI groups:
CFormCollection, CSortable, CSplitter, CStepper, CTour, CTransferList,
CVirtualList, and CTimeline. CTimeline is missing from the list in docs/design/vue.md:4352 and has no browser fill-scope test.
Where Citry refuses. In _vue/direct_capture.py, a fill whose
receiver is a flattened transparent component, and whose author does not
enclose that receiver, is copied into the receiving template
(copied_outside_author, :2025-2043). Copying is safe only when the
fill reads no Vue data, so a fill that does is refused at :2194-2197
with describe_fill_outside_author (:754-792). The message names the
author, the line, the first read, and the group, and tells the user to
write the content above the group. A v-slot fill on the same path is
refused earlier (:2184-2193). The rule and its reasons are in docs/design/vue.md:4313-4502, the user docs in docs_site/content/vue/slots.md:325-445 and the CTabs API page.
Tests: test_vue_direct_relationships.py:542, 569, 594 and three test_storybook_spike.py tests (:306, 340, 373).
Provide and inject. Python <c-provide> and self.inject() follow
where content renders. On the Vue side, generated code emits no provide/inject; only the i18n plugin uses them
(citry-i18n-vue.ts:736-739). One Vue app runs per page manifest
(client.js:1174-1201, 4130-4133), so the group, the author, and the
receiver are ordinary Vue components in one tree.
Teleport is rejected when a template loads
(parser.rs:2930-2970), is missing from the compiler allowlists, and
the Rust server renderer declines it (server_render.rs:661-669).
Nothing exists for passing a slot function from one component to a
component that is not below it.
Why Vue data cannot follow the content today
Vue keeps a slot's scope by passing the slot down the tree as a function
(withCtx pins the author). TabLabels sits below CTabs, so it never
creates the component that renders its items' content, and it has no way
to hand that function over. Citry can only copy the content into the
panel's template, where Vue names would point at the wrong component, so
it refuses.
Options
A. The author registers its content with the group (recommended)
The author compiles the item content in its own definition, as for any
fill, and registers the resulting slot function in a page-level registry
under a key. The group's panel renders whatever is registered under that
key, in place of the copied content. Because the function keeps the
author's scope, v-text="label", @click, and v-model read and change TabLabels' data.
Assembler (direct_capture.py): in the copied_outside_author
branch, keep the fill in the author's definition, attached to the
item's call (<x-item><template v-slot:['S']>...</template></x-item>),
and write a small <citry-relocated> placeholder in the receiving
template instead of the copy. The key is built from the author
occurrence, the slot site, and the keyed-row route, and is sent as data,
not written into template text, because instances share definitions.
Browser runtime (citry-client): a reactive registry per app. The
item's component registers a getter for its slot on setup and removes
it on unmount. <citry-relocated> renders the registered function with
any slot props, so the group can pass per-item props such as active
through feat(vue): pass Vue data to a fill with <c-slot :row> and <c-fill v-slot> #445's pattern.
Server HTML: the Rust renderer needs a matching step to write the
registered content into the panel. Without it, the panel is a
browser-built shell: the Python HTML shows first and the browser builds
the content after it starts. The first PR can ship with the shell and a
later PR can add the Rust step.
Order: Vue mounts depth-first in template order. CTabs writes its
items before its panels, so registration happens before a panel renders.
A group whose target comes before its source would not match on the
first render, so the assembler rejects that shape, or makes the target
a shell.
Unchanged: ARIA ids and item order come from Python as today, and the
content renders inside the panel element, so screen readers follow the
real DOM order.
Cost: medium to high. The hard part is in the assembler: the fill
body is transformed only when the walk reaches the receiver, after it
has left the author's call. The author's definition needs a placeholder
that is filled in later. Definition sharing and the "not consumed" check
must account for it.
B. Teleport
The content renders in the author's own Vue tree and Vue moves the DOM
nodes into the panel. Scope is free and the DOM really moves, but the
panel is itself a Vue element of the group, and Vue's hydration deletes
server children it did not create. Whichever of the panel or the Teleport
hydrates second removes or re-creates the moved nodes, and a panel update
that re-creates the element orphans them. It also needs Teleport support
added to the parser, compiler, Rust renderer, and both HTML writers.
High cost and high risk; rejected.
C. Keep the limit and improve the error and docs
The docs already describe the case. Small fixes: add CTimeline to the
group list and give it a browser fill-scope test, mention the
transparent-author option and its trap in the error, and say that a v-for inside such content counts as a read. Tiny cost. This is the
fallback if A's assembler change does not fit.
Recommendation
A, in three PRs:
The assembler and runtime mechanism with a browser-built panel shell,
proved with a small test component pair (an author with js_data and a
group that relocates its items), not CTabs.
The Rust renderer step, so the server writes the relocated content and
the shell goes away.
CTabs as the first Citry UI user, then the other eight groups, after the
Citry UI pause (v1.1). C's documentation fixes can land meanwhile.
Error modes
Input
Result
The group's target comes before the item's source in the page
Render error naming the group and the author (or a browser-built shell, if that proves simpler)
No item registers under a key the group renders
The panel renders empty; a development-mode console warning names the key
An item registers twice under one key (a duplicate value)
The group's existing duplicate check fails first in Python; the runtime keeps the first and warns
The author re-renders through Events
Its slot functions are re-registered; a version counter makes the panel update even when no reactive value changed
The author component has no Vue (js missing)
No change: the content reads no Vue data, so it is copied as today
A page without Vue
No change
What would show this is wrong
The assembler cannot keep the fill in the author's definition without
breaking definition sharing: two instances of TabLabels with different
items would need different definitions. A test with two instances and
different items would show it.
Vue does not mount the author's items before the group's panels in the
real CTabs tree, so the first render cannot match. A browser test of the
test pair, checking for hydration warnings, would show it.
An Events update of the author alone does not reach the panel, because
the registry holds a stale function. A browser test that updates only the
author would show it.
A keyed list of items re-orders and the panel shows the wrong item's
content.
Proof plan for PR 1
Assembly test: the item's v-text="label" appears only in the author's
definition, and the group's template holds the placeholder.
Browser test: the content shows label; @click and v-model change
the author's data; no hydration warning; a keyed variant reorders
correctly; a target-before-source variant is rejected or shelled.
Reuse _declaration_receiver and _sibling_author_page from test_vue_direct_relationships.py as the starting point.
Activity
JuroOravec commentedon Oct 3, 2026
note - also consider this angle - maybe instead of allowing for Citry and Vue slots to get disconnected, we could add proper support for teleports and do it with them.
JuroOravec commentedon Oct 28, 2026
Parked for after 0.7.0 (effort is medium to hard). This is the design worked out so far, kept here so the work can resume from it.
#169: content written in another component can't read its Vue data
Status: exploration note for the maintainer. No code written. Read on
origin/main
492199e7d. Line numbers are from that commit.The problem
A group component such as Citry UI's
CTabsshows each item's contentsomewhere other than where the item is written: each
CTabstores itsdefault slot, and
CTabscalls it again inside its own panels. When theitems are written by a different component than the one holding the
group, and their content reads that component's Vue data, rendering fails:
Content with only Python values works from anywhere, and items written
directly by the component that holds
<c-CTabs>work too.Prior art
CTabs.template_datashares a registrywith
self.provide(). EachCTabstores its default slot as a PythonSlotand renders nothing in place.CTabs' template holds the itemsfirst, then the panels, which call the stored slots again
(
citry_ui/components/ctabs/ctabs.py:39-54, 235, 262-308, 794-867, 918-982). The same pattern is used by eight other Citry UI groups:CFormCollection, CSortable, CSplitter, CStepper, CTour, CTransferList,
CVirtualList, and CTimeline. CTimeline is missing from the list in
docs/design/vue.md:4352and has no browser fill-scope test._vue/direct_capture.py, a fill whosereceiver is a flattened transparent component, and whose author does not
enclose that receiver, is copied into the receiving template
(
copied_outside_author,:2025-2043). Copying is safe only when thefill reads no Vue data, so a fill that does is refused at
:2194-2197with
describe_fill_outside_author(:754-792). The message names theauthor, the line, the first read, and the group, and tells the user to
write the content above the group. A
v-slotfill on the same path isrefused earlier (
:2184-2193). The rule and its reasons are indocs/design/vue.md:4313-4502, the user docs indocs_site/content/vue/slots.md:325-445and the CTabs API page.Tests:
test_vue_direct_relationships.py:542, 569, 594and threetest_storybook_spike.pytests (:306, 340, 373).7347b21fband754ca907e) added:props on outlets,v-slotpatterns on fillfunctions, forwarding of scoped fills, and server HTML for them
(
server_render.rs:236-251, 736-791). They do not cover a fill whoseauthor is not above its receiver: that path refuses scoped fills too.
<c-provide>andself.inject()followwhere content renders. On the Vue side, generated code emits no
provide/inject; only the i18n plugin uses them(
citry-i18n-vue.ts:736-739). One Vue app runs per page manifest(
client.js:1174-1201, 4130-4133), so the group, the author, and thereceiver are ordinary Vue components in one tree.
(
parser.rs:2930-2970), is missing from the compiler allowlists, andthe Rust server renderer declines it (
server_render.rs:661-669).component that is not below it.
Why Vue data cannot follow the content today
Vue keeps a slot's scope by passing the slot down the tree as a function
(
withCtxpins the author).TabLabelssits belowCTabs, so it nevercreates the component that renders its items' content, and it has no way
to hand that function over. Citry can only copy the content into the
panel's template, where Vue names would point at the wrong component, so
it refuses.
Options
A. The author registers its content with the group (recommended)
The author compiles the item content in its own definition, as for any
fill, and registers the resulting slot function in a page-level registry
under a key. The group's panel renders whatever is registered under that
key, in place of the copied content. Because the function keeps the
author's scope,
v-text="label",@click, andv-modelread and changeTabLabels' data.direct_capture.py): in thecopied_outside_authorbranch, keep the fill in the author's definition, attached to the
item's call (
<x-item><template v-slot:['S']>...</template></x-item>),and write a small
<citry-relocated>placeholder in the receivingtemplate instead of the copy. The key is built from the author
occurrence, the slot site, and the keyed-row route, and is sent as data,
not written into template text, because instances share definitions.
citry-client): a reactive registry per app. Theitem's component registers a getter for its slot on setup and removes
it on unmount.
<citry-relocated>renders the registered function withany slot props, so the group can pass per-item props such as
activethrough feat(vue): pass Vue data to a fill with <c-slot :row> and <c-fill v-slot> #445's pattern.
registered content into the panel. Without it, the panel is a
browser-built shell: the Python HTML shows first and the browser builds
the content after it starts. The first PR can ship with the shell and a
later PR can add the Rust step.
CTabswrites itsitems before its panels, so registration happens before a panel renders.
A group whose target comes before its source would not match on the
first render, so the assembler rejects that shape, or makes the target
a shell.
content renders inside the panel element, so screen readers follow the
real DOM order.
body is transformed only when the walk reaches the receiver, after it
has left the author's call. The author's definition needs a placeholder
that is filled in later. Definition sharing and the "not consumed" check
must account for it.
B. Teleport
The content renders in the author's own Vue tree and Vue moves the DOM
nodes into the panel. Scope is free and the DOM really moves, but the
panel is itself a Vue element of the group, and Vue's hydration deletes
server children it did not create. Whichever of the panel or the Teleport
hydrates second removes or re-creates the moved nodes, and a panel update
that re-creates the element orphans them. It also needs Teleport support
added to the parser, compiler, Rust renderer, and both HTML writers.
High cost and high risk; rejected.
C. Keep the limit and improve the error and docs
The docs already describe the case. Small fixes: add CTimeline to the
group list and give it a browser fill-scope test, mention the
transparent-author option and its trap in the error, and say that a
v-forinside such content counts as a read. Tiny cost. This is thefallback if A's assembler change does not fit.
Recommendation
A, in three PRs:
proved with a small test component pair (an author with
js_dataand agroup that relocates its items), not CTabs.
the shell goes away.
Citry UI pause (v1.1). C's documentation fixes can land meanwhile.
Error modes
jsmissing)What would show this is wrong
breaking definition sharing: two instances of
TabLabelswith differentitems would need different definitions. A test with two instances and
different items would show it.
real
CTabstree, so the first render cannot match. A browser test of thetest pair, checking for hydration warnings, would show it.
the registry holds a stale function. A browser test that updates only the
author would show it.
content.
Proof plan for PR 1
v-text="label"appears only in the author'sdefinition, and the group's template holds the placeholder.
label;@clickandv-modelchangethe author's data; no hydration warning; a keyed variant reorders
correctly; a target-before-source variant is rejected or shelled.
_declaration_receiverand_sibling_author_pagefromtest_vue_direct_relationships.pyas the starting point.