Skip to content

U0016 egui-checklist-menu

Rule: A checklist of checkboxes sits in the shared checklist widget, not a menu_button that closes on each click.

Code U0016 (stable, never reused)
Id egui-checklist-menu
Category egui
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded off
ui off
egui warn a menu_button closes on the first tick inside it; ve_basics::Checklist keeps it open for several
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
menu-calls list of strings ["menu_button"] calls whose closure draws a menu that closes on each click inside it
checkbox-calls list of strings ["checkbox"] calls that make a checkbox
min-checkboxes integer 2 checkboxes inside a menu's closure before it is a checklist
widget string "ve_basics::Checklist" the shared checklist widget, named in the help
toolkits list of strings ["egui", "eframe", "iced", "slint", "gtk4", "relm4", "dioxus", "leptos", "yew", "floem", "xilem", "makepad-widgets"] UI toolkits: a crate that depends on one directly is a UI crate, unless the crate map says ui = false

Why

egui closes a menu_button's menu on the first click inside it. A dropdown of checkboxes meant to tick several options needs the menu to stay open while ticking, which vhrd_egui's checklist widget does; a plain menu_button closure full of checkbox calls closes after the first tick, hiding the rest of the list from the person mid-choice.

The lint reports, in UI crates, a menu-calls call (menu_button) whose last argument is a closure holding min-checkboxes or more calls of checkbox-calls (checkbox), anywhere in the closure's body. Findings are estimates: a single checkbox below min-checkboxes, or one meant to close the menu on its own tick, is not a checklist.

How to fix

Replace the menu_button closure with the shared checklist widget (widget, ve_basics::Checklist by default), which keeps the menu open while the person ticks several boxes.

Configure

[lints.egui-checklist-menu]
level = "deny"
menu-calls = ["menu_button"]
checkbox-calls = ["checkbox"]
min-checkboxes = 2
widget = "ve_basics::Checklist"
toolkits = ["egui", "eframe", "iced", "slint", "gtk4", "relm4", "dioxus", "leptos", "yew", "floem", "xilem", "makepad-widgets"]
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(egui-checklist-menu) <reason> (waivers); the code works there too, as in [lints.U0016].