fix multiselect combobox

This commit is contained in:
2026-07-13 15:21:42 -04:00
parent d52151cc1a
commit 5230bd6702
11 changed files with 664 additions and 58 deletions

View File

@@ -208,6 +208,30 @@ func SetScrollLeft(r *vdom.Ref, x float64) {
}
}
// OverflowsX reports whether an element's content is wider than the box it is
// clipped to — i.e. something is hidden.
//
// It compares scrollWidth (the full content) against clientWidth (the visible content
// box). Measure/getBoundingClientRect is the WRONG comparison here: it reports the
// element's own border box, which is by definition the size it was clipped to, so it
// can never reveal an overflow.
//
// A detached or display:none element has no layout and reports 0/0; that is not an
// overflow, so it answers false rather than a misleading true.
func OverflowsX(r *vdom.Ref) bool {
n, ok := node(r)
if !ok {
return false
}
client := n.Get("clientWidth").Float()
if client == 0 {
return false
}
// Sub-pixel layout means scrollWidth can exceed clientWidth by a hair on content
// that visually fits. Round up to whole pixels before believing it.
return n.Get("scrollWidth").Float() > client+1
}
// ---- hit testing (outside-click) ----
// Contains reports whether target lies inside r's subtree. target is an