active-leaf-routes through invocation treeStatus: backlog Priority: P2 Created: 2026-02-18 Owner: AI
active-leaf-routes and its helper leaf-route? only inspect the root routing chart's elements-by-id and configuration. An istate like ::ui/AdminPanel has :route/target but no child route states within the root chart (the children are in the invoked child chart). So leaf-route? incorrectly returns true for it.
When a user is at AdminPanel > AdminUserDetail, active-leaf-routes returns #{::ui/AdminPanel} instead of #{::ui/AdminUserDetail}. This defeats the primary use case: highlighting the active nav link or conditionally rendering based on which leaf screen is showing.
The library's own internal code (deep-busy?, deep-configuration->url) already handles this correctly by walking [:invocation/id target-key] into child sessions recursively. active-leaf-routes needs the same treatment.
active-leaf-routes must walk the invocation tree to find the true leaf route states across chart boundariesseen set like deep-busy?)leaf-route? and has-routes? may remain as-is (they're correct for single-chart inspection) but their docstrings should note they don't cross invocation boundaries[:set :qualified-keyword] — the state IDs of the leaf route states (which may be in child charts)deep-active-leaf-routesModel after deep-busy? (ui_routes.cljc:302-325) and deep-configuration->url (route_url.cljc:289-329):
(deep-active-leaf-routes app-ish) => #{leaf-state-ids...}
Walk from the root routing session:
:route/target, no child routes in this chart), check for a child invocation via [:invocation/id target-key] in the session's local dataactive-leaf-routesEither:
active-leaf-routes to active-leaf-routes-shallow (or similar) for callers that intentionally want single-chart inspectionactive-leaf-routes in-place with the deep version (breaking change, but the current behavior is arguably a bug)Recommended: replace in-place, since the shallow version returns wrong answers for istates and no one should rely on that.
leaf-route?: add note that it inspects a single chart only and does not cross invocation boundarieshas-routes?: same notesrc/main/com/fulcrologic/statecharts/integration/fulcro/ui_routes.cljc — rewrite active-leaf-routes, update docstrings on leaf-route? and has-routes?src/test/com/fulcrologic/statecharts/integration/fulcro/ui_routes_test.cljc — add tests for deep leaf detection through istates and parallel regionsCan you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |