From ea930e7b735cb2aa86099ae011a3553c4afd32d1 Mon Sep 17 00:00:00 2001 From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com> Date: Tue, 14 Jul 2026 11:25:58 +0300 Subject: [PATCH] Fixing --- detailsView.go | 28 +++++++++++++++++++++++++++- listView.go | 3 ++- sessionUtils.go | 2 +- tableView.go | 3 ++- viewByID.go | 2 +- viewsContainer.go | 7 ++----- 6 files changed, 35 insertions(+), 10 deletions(-) diff --git a/detailsView.go b/detailsView.go index 8216884..bc2e359 100644 --- a/detailsView.go +++ b/detailsView.go @@ -1,6 +1,9 @@ package rui -import "strings" +import ( + "iter" + "strings" +) // Constants for [DetailsView] specific properties and events const ( @@ -80,6 +83,29 @@ func (detailsView *detailsViewData) Views() []View { return views } +func (detailsView *detailsViewData) ViewSeq() iter.Seq[View] { + if detailsView.views == nil { + detailsView.views = []View{} + } + + return func(yield func(View) bool) { + if summary := detailsView.Get(Summary); summary != nil { + switch summary := summary.(type) { + case View: + if !yield(summary) { + return + } + } + } + + for _, view := range detailsView.views { + if !yield(view) { + return + } + } + } +} + func (detailsView *detailsViewData) setFunc(tag PropertyName, value any) []PropertyName { switch tag { case Summary: diff --git a/listView.go b/listView.go index 2455b7a..874b8d7 100644 --- a/listView.go +++ b/listView.go @@ -3,6 +3,7 @@ package rui import ( "fmt" "iter" + "slices" "strconv" "strings" ) @@ -159,7 +160,7 @@ func (listView *listViewData) init(session Session) { } func (listView *listViewData) Views() []View { - return listView.items + return slices.Clone(listView.items) } func (listView *listViewData) ViewSeq() iter.Seq[View] { diff --git a/sessionUtils.go b/sessionUtils.go index 442f027..2dbe672 100644 --- a/sessionUtils.go +++ b/sessionUtils.go @@ -45,7 +45,7 @@ func viewByHTMLID(id string, startView View) View { return startView } if container, ok := startView.(ParentView); ok { - for _, view := range container.Views() { + for view := range container.ViewSeq() { if view != nil { if v := viewByHTMLID(id, view); v != nil { return v diff --git a/tableView.go b/tableView.go index 4523560..3e06f4d 100644 --- a/tableView.go +++ b/tableView.go @@ -3,6 +3,7 @@ package rui import ( "fmt" "iter" + "slices" "strconv" "strings" ) @@ -1692,7 +1693,7 @@ func (table *tableViewData) ReloadCell(row, column int) { } func (table *tableViewData) Views() []View { - return table.cellViews + return slices.Clone(table.cellViews) } func (table *tableViewData) ViewSeq() iter.Seq[View] { diff --git a/viewByID.go b/viewByID.go index eb7ff11..2ffd7a2 100644 --- a/viewByID.go +++ b/viewByID.go @@ -44,7 +44,7 @@ func ViewByID(rootView View, id string, ids ...string) View { } func viewByID(rootView ParentView, id string) View { - for _, view := range rootView.Views() { + for view := range rootView.ViewSeq() { if view != nil { if view.ID() == id { return view diff --git a/viewsContainer.go b/viewsContainer.go index 42e50ad..f88f6de 100644 --- a/viewsContainer.go +++ b/viewsContainer.go @@ -2,6 +2,7 @@ package rui import ( "iter" + "slices" "strings" ) @@ -68,12 +69,8 @@ func (container *viewsContainerData) setParentID(parentID string) { func (container *viewsContainerData) Views() []View { if container.views == nil { container.views = []View{} - } else if count := len(container.views); count > 0 { - views := make([]View, count) - copy(views, container.views) - return views } - return []View{} + return slices.Clone(container.views) } func (container *viewsContainerData) ViewSeq() iter.Seq[View] {