Refactor: results expose Element as a named field

Every component result type now names its element Element instead of
embedding *ui.Element. The eleven element-plus-changed results
(AccordionView, CarouselView, CollapsibleView, ImageViewerView,
PaginationResult, StepsResult, SidebarResult, TabsResult, RatingParts,
FileDropZoneParts, TransferParts) fold into ChoiceResult.

Fixes four Gallery demos where .Width(...).Changed() read the element's
flag instead of the component's: Accordion, MultiSelect, Cascader,
TreeSelect. TestDataAccordionDemoLogsChange covers the Accordion.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 13:35:53 -04:00
1 parent 078dcab8b4
commit 8880865021
73 files changed
+163 -245

No files matched your search

+5 -5
View File
@@ -31,8 +31,8 @@ type DescriptionListOptions struct {
// DescriptionListView is a built DescriptionList and what happened to it in this frame.
type DescriptionListView struct {
*ui.Element
copied int
Element *ui.Element
copied int
}
// Copied returns the index of the item whose value was copied in this frame.
@@ -69,15 +69,15 @@ func DescriptionList(c *ui.Context, items []DescriptionItem, opts DescriptionLis
}
return max(1, min(most, int(math.Floor(float64((w+gap)/(minW+gap))))))
}
cols := fit(v.Bounds().W)
v.Draw(func(p *ui.Painter, r ui.Rect) {
cols := fit(v.Element.Bounds().W)
v.Element.Draw(func(p *ui.Painter, r ui.Rect) {
if fit(r.W) != cols {
// The new width needs other columns: build again.
c.Invalidate()
}
})
now := c.Now()
v.Columns(cols).Children(func() {
v.Element.Columns(cols).Children(func() {
for i, it := range items {
cell := ui.Column(c).Gap(u).MinWidth(0)
if it.Span < 0 || it.Span > cols {