Skip to main content

flip_open_dropdown_panels

Function flip_open_dropdown_panels 

Source
pub fn flip_open_dropdown_panels(
    viewport: Option<Res<'_, Viewport>>,
    store: Res<'_, PropertyStore>,
    headers: Query<'_, '_, (&DropdownButton, &Transform, Option<&PopupGap>)>,
    parents: Query<'_, '_, &ChildOf>,
    transforms: Query<'_, '_, &Transform>,
    panels: Query<'_, '_, (Entity, &PopupPanel, &mut Style, &mut StyleOverrides)>,
)
Expand description

Anchor each open dropdown panel below its trigger header, flipping it above when the panel’s bottom edge would fall past the viewport bottom. Runs after the first layout pass has measured the panel (mirrors the tooltip’s spawn-then-measure ordering).

The panel is position: absolute inside its <if> wrapper (its containing block), so the viewport-space origin from anchored_popup_origin is converted to a local inset.top against the containing block; inset.bottom is released to auto (NaN) so the panel sizes to its option list in both orientations. Menu panels have no queryable trigger and are left untouched here - their dismissal still works via dismiss_popups_on_outside_press.

The placement is held in StyleOverrides while the panel is open, so a restyle meanwhile keeps it, and let go of on close.