Skip to content

Anchored popups: report which side a placement flipped to #362

Done

Description

@square3ang

An anchored popup flips to the other side when there's no room. A nested submenu should open on the side its parent opened (a parent that flipped left opens its child to the left too), but the app can't learn the side Rune actually used.

Wanted: the resolved Side/Align of an anchored element, readable like Cx::layout (or passed to a callback).

Context: found while porting a chat client's desktop UI to Rune (pinned at 565de6b).

Activity

  1. Hona commented on Nov 24, 2026

    @Hona
    Member

    Implemented on dev in #1939 (fa636374e).

    You can now read an anchored overlay's resolved (Side, Align) after RTL mirroring, zoom, and flip clamping with Cx::anchor_placement(key) (or rune::memo::anchor_placement(key) inside components without Cx). It participates in the existing layout-read settle loop and memo invalidation, re-running views and memos only when the resolved placement changes (never on non-flipping scrolls or resizes):

    let parent_side = cx.anchor_placement("parent-menu").map_or(Side::Right, |(side, _)| side);
    let submenu = col().key("submenu").w(120.0).h(80.0)
        .anchored("menu-item", parent_side, Align::Start, 4.0);

    This follows Floating UI's resolved placement after flip middleware, paired with Rune's Cx::layout_with / memo::layout read conventions. In right-to-left subtrees it returns the physical resolved (Side, Align); if you need a logical or callback form instead, feel free to say so.

    Verified with headless Runtime tests on Windows and macOS (unflipped, side flips, align flips, RTL mirroring, chained submenus, scroll/memo invalidation, resize settling), Linux cargo check --tests, and wasm32 WebGPU/WebGL checks. You can also see it in examples/kit-gallery (rune-popover--bounded). Not checked in a live desktop window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions