Refactor: a disabled wrapper alone blocks choice bases
TestBasesBlockedByDisabledWrapper focuses CheckboxBase, RadioBase, SwitchBase and ToggleBase, flips their wrapper to Disabled and presses Space: none changes its value, and each does without the flip. So choiceTarget goes from Switch, Toggle and MultiSelect, and PopupMenu Check drops its copy; TestChoiceDisabledWhileFocused and TestDropdownMenuCheckDisabledThisFrameKeepsValue still pass. ComboboxBase is different: TestComboboxBaseIgnoresDisabledWrapper shows a focused one still takes typing under a disabled wrapper, so Combobox keeps a copy, now inline as its only user.
This commit is contained in:
6 files changed
+70
-22
No files matched your search
+7
-1
@@ -55,8 +55,14 @@ func Combobox(c *ui.Context, value *string, options []string, opts ComboboxOptio
|
||||
refocus := ui.Local(f, comboboxKey{"refocus"}, func() bool { return false })
|
||||
var p *ui.ComboboxParts
|
||||
f.Children(func() {
|
||||
// A focused ComboboxBase takes typing under a disabled wrapper, so it edits a copy.
|
||||
target := query
|
||||
if opts.Disabled {
|
||||
cp := *query
|
||||
target = &cp
|
||||
}
|
||||
ui.Row(c).Key(*gen).Grow(1).Children(func() {
|
||||
p = ui.ComboboxBase(c, choiceTarget(query, opts.Disabled))
|
||||
p = ui.ComboboxBase(c, target)
|
||||
})
|
||||
if *refocus {
|
||||
p.Input.Focus()
|
||||
|
||||
Reference in new issue
Block a user