Repository navigation
fix(ui): type the shadow-root walk and the disclosure state for TypeScript - #534
Merged
Merged
Conversation
…cript Since #457 wrote these components' `js` as single string literals, the editor's TypeScript check reads them, and main's Ubuntu Python test jobs fail `test_citry_ui_components_have_no_typescript_or_ty_findings` with six ts2339 findings: - chover_card, cmulti_select, cpopover and ctooltip walk outward from an inline trigger to the nearest ancestor with a box of its own, stepping out of a shadow root with `box.getRootNode().host`. TypeScript types `getRootNode()` as returning a `Node`, which has no `host`. The walk now checks `instanceof ShadowRoot` first, the way `_anchored_layer.py` does, and types `box` as `Element`, because TypeScript types a shadow root's host as `Element`. A document root still ends the walk, as before. - cdisclosure keeps its browser-side state in `root.__citryUiDisclosureRuntime`. The root is now cast to an element type that declares that property, the way caccordion, clistbox, ctag and ctree already do. cmenu has the same walk in `_runtime_source`, which is built by concatenation, so TypeScript does not check it. It gets the same change so the inline copies match. cselect's copy in `runtime.source.js` keeps the old form, because changing it means rebuilding its minified file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec
force-pushed
the
fix/citry-ui-ts-findings
branch
from
October 28, 2026 22:28
1c5f394 to
52b5a18
Compare
This was referenced Oct 28, 2026
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.
Main's Ubuntu Python test jobs fail
packages/py/citry_ui/tests/test_citry_ui_type_check.py::test_citry_ui_components_have_no_typescript_or_ty_findingswith six TypeScript ts2339 findings. This PR fixes the types rather than suppressing them.Why it started failing
The editor's TypeScript check reads a component's inline
jsonly when it is a single string literal. #457 (8bfb23e) turned theANCHORED_LAYER_RUNTIME_JS + r"""..."""concatenations into single literals, so these scripts were checked for the first time. In the CI run at 33c9531, the commit before #457, this test reported no findings. The run at 8bfb23e (#457) is the first to report these six. The code that causes them was already there; #457 only made TypeScript read it.What changes
hostonNode(chover_card, cmulti_select, cpopover, ctooltip). These components walk outward from an inline trigger to the nearest ancestor that is not inline, because a ResizeObserver reports nothing for an inline element. On the way they step out of a shadow root to its host. TypeScript typesbox.getRootNode()as returning aNode, which has nohost. The walk now checksinstanceof ShadowRootfirst, as_anchored_layer.pyandcmenu.py:1671already do. It typesboxasElement, because TypeScript types a shadow root's host asElement. A document root still ends the walk, so the behavior is the same for nodes in the page's own document.__citryUiDisclosureRuntimeonHTMLDivElement(cdisclosure). The disclosure keeps its browser-side state on its root element. The root is now cast to an element type that declares that property, as caccordion, clistbox, ctag and ctree already do._runtime_source, which is built by concatenation, so TypeScript does not check it. It gets the same change so the inline copies match.Five
runtime.source.jsfiles still readgetRootNode().host:cselect:121(the same walk),ctour:334,ccascader:170,ccolor_picker:40andccontext_menu:536/565/1453. TypeScript does not check them, because each one is the source of a minifiedruntime.min.js, so this PR leaves them alone. Changing them means rebuilding the minified files, which suits a separate sweep.Evidence
string | boolean | string[], lines 934 to 963), with or without this change. CI does not report those, so they most likely come from my local environment, which uses an older Rust core.test_asset_budgets.pypasses, andpnpm run citry-ui:check-assetspasses. ruff and ruff format pass.0.420.0+citry.6, and main needscitry.7(fix: read v-pre content as plain, as Vue 3.5 does #525), so rendering stops with "unknown compiler identity". This PR's CI runs them.🤖 Generated with Claude Code