Skip to content

A layout drawn inside another's draw closure removes the outer drawing shell; the outer layout's next owned button panics #278

Closed

Description

@samitbasu

Reported by a consumer on v0.1.0-m8.16.

Placed::draw enters shell::Drawing, which stores the layout's Handle under one key per viewport. Its Drop removes the key instead of restoring what was there. When a draw closure of layout A draws layout B (an egui Popup or Area with eggshell content), B's guard removes the key as B finishes. A's next owned button then calls nav::take_activation, which calls ui.shell(), and panics (Ui::shell is for the draw closures of a Placed).

Decided (user, 2026-11-16), all three parts of the reporter's patch:

  1. Drawing restores the handle it displaced on drop, so guards nest like a stack.
  2. A public ShellExt::try_shell() -> Option<Shell>. The library's Ui-only callers (keyboard activation, tooltip registration, multiline focus) use a crate-private shell_or_warn, which skips just that step outside every Placed::draw and warns once per context and step, in all builds. shell() still panics outside every draw (a programming error).
  3. Docs: layouts may nest.

Tests: the reproduction, the outer closures seeing their shell again after the inner layout, and no shell in plain egui.

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

    bugv0.1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions