Skip to content

Dropdowns are never clamped or flipped #59

Description

@Vmarcelo49

The dropdown popup always opens downwards from the bottom left of the button and is never
clamped or flipped:

https://github.com/ebitengine/debugui/blob/85357fb/dropdown.go#L101-L112

dropdownPos := image.Pt(bounds.Min.X, bounds.Max.Y)

The widget never reads c.screenWidth / c.screenHeight, so when the button is near the
bottom of the screen the popup runs off it.

In the first screenshot the screen is 320x240, the window is at (10,130)-(310,230) and the
dropdown has 5 options. The button ends at y=199 and the popup is 120px tall, so it is drawn
from y=199 to y=319, 79px below the screen. Only Option 1 and part of Option 2 are on
screen; Option 3 to Option 5 cannot be seen or reached, because the content fits the popup
body and there is no scrollbar to bring them into view.

Image

The second image is the same case with the popup opened above the button instead, just to
illustrate the expected result. I am not proposing that specific approach, only that the popup
stays inside the screen somehow.

Image

Repro, with the button near the bottom of a small window:

ctx.Window("test", image.Rect(10, 130, 310, 230), func(layout debugui.ContainerLayout) {
	ctx.Text("Dropdown near the bottom")
	ctx.Dropdown(&selected, []string{"Option 1", "Option 2", "Option 3", "Option 4", "Option 5"})
})

The bounds are also only computed when the popup opens, so if the parent window is moved or
scrolled while the popup is open it does not follow the button.

Activity

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