From 9f280a8d84c183c74db3452d60a4601aa343813c Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Fri, 29 Mar 2024 20:23:28 -0500 Subject: [PATCH] Fix child fields with the web history (#2172) Co-authored-by: Jonathan Kelley --- packages/router-macro/src/lib.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/router-macro/src/lib.rs b/packages/router-macro/src/lib.rs index c6fd70bfd..f6ac186b3 100644 --- a/packages/router-macro/src/lib.rs +++ b/packages/router-macro/src/lib.rs @@ -462,14 +462,25 @@ impl RouteEnum { } } for route in &self.routes { - for segment in &route.segments { - if segment.name().as_ref() == Some(field) { - from_route = true + match &route.ty { + RouteType::Child(child) => { + if let Some(child) = child.ident.as_ref() { + if child == "child" { + from_route = true + } + } } - } - if let Some(query) = &route.query { - if query.contains_ident(field) { - from_route = true + RouteType::Leaf { .. } => { + for segment in &route.segments { + if segment.name().as_ref() == Some(field) { + from_route = true + } + } + if let Some(query) = &route.query { + if query.contains_ident(field) { + from_route = true + } + } } } }