refactor(hierarchy): name no screen for a tree Transitional calls a cross-fade

ScreenName kept its own reading of the route markers and disagreed with
Transitional on a marker repeated by a nested node: it named the screen on
a step the runner was skipping as unsettled. One reading now.
This commit is contained in:
pj committed 2026-09-05 22:31:17 +05:30
1 parent 8dc4d08bc1
commit db43f450bc
2 files changed
+7 -20

No files matched your search

+7 -11
View File
@@ -669,9 +669,7 @@ func (t *Tree) Transitional() bool {
// ScreenName names the route this tree shows: the driver-set screen when the // ScreenName names the route this tree shows: the driver-set screen when the
// platform reports one (web), otherwise the resource id ending in "Screen" that // platform reports one (web), otherwise the resource id ending in "Screen" that
// marks the route composable. A tree carrying two different route ids is a // marks the route composable. A transitional tree names no screen.
// cross-fade in flight and names no screen, which is the same reading
// Transitional gives it.
func (t *Tree) ScreenName() string { func (t *Tree) ScreenName() string {
if t == nil || len(t.Elements) == 0 { if t == nil || len(t.Elements) == 0 {
return "" return ""
@@ -679,17 +677,15 @@ func (t *Tree) ScreenName() string {
if screen := t.Elements[0].Screen; screen != "" { if screen := t.Elements[0].Screen; screen != "" {
return screen return screen
} }
name := "" if t.Transitional() {
for _, element := range t.Elements {
if !strings.HasSuffix(element.ResourceID, "Screen") {
continue
}
if name != "" && name != element.ResourceID {
return "" return ""
} }
name = element.ResourceID for _, element := range t.Elements {
if strings.HasSuffix(element.ResourceID, "Screen") {
return element.ResourceID
} }
return name }
return ""
} }
// Find returns the first element matching the selector, or nil. // Find returns the first element matching the selector, or nil.
-9
View File
@@ -1840,15 +1840,6 @@ func TestScreenNameNamesTheRouteTheTreeShows(t *testing.T) {
]}`, ]}`,
"HomeScreen", "HomeScreen",
}, },
{
"route marker repeated by a nested node",
`{"attributes": {"bounds": "[0,0,10,10]"}, "children": [
{"attributes": {"resource-id": "HomeScreen", "bounds": "[0,0,10,10]"}, "children": [
{"attributes": {"resource-id": "HomeScreen", "bounds": "[0,0,10,5]"}, "children": []}
]}
]}`,
"HomeScreen",
},
{ {
"cross-fade names no screen", "cross-fade names no screen",
`{"attributes": {"bounds": "[0,0,10,10]"}, "children": [ `{"attributes": {"bounds": "[0,0,10,10]"}, "children": [