Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

color_edit popup closes on single click when displaced by window constraints #3394

Closed
IllusionMan1212 opened this issue Sep 27, 2023 · 0 comments · Fixed by #3395
Closed
Labels
bug Something is broken

Comments

@IllusionMan1212
Copy link

IllusionMan1212 commented Sep 27, 2023

Describe the bug
When a color picker made by calling color_edit_button_srgb (or the other color_edit funcs) is displaced due to the window being too small for it to render in it's natural position, clicking inside the picker popup will cause it to close.
So if a picker popup is displaced up by half it's height, clicking on the lower half of the it works as expected (no close) and clicking on the upper half will cause it to close. I believe this is due to the positioning of the picker popup not being updated when the displacement happens. The gif in the screenshots section demonstrates the bug.

To Reproduce
Steps to reproduce the behavior:

  1. Create a eframe::run_simple_native with a default CentralPanel application
  2. Add some space using ui.add_space() and add a single color_edit_* widget
  3. Shrink window to a small size so that the picker popup would displace a fair amount
  4. Open picker popup and try clicking on it in various places and it should close.

The steps above are implemented in a simple repro using eframe and egui in the below gist
https://gist.github.com/IllusionMan1212/d9b2f71d1977db1579df9d30d143fcdd

Expected behavior
I expect the picker popup to not close when the click happens inside of it regardless if it's displaced or not.

Screenshots
egui-bug

Desktop (please complete the following information):

  • OS: Ubuntu 22.04
  • Browser Firefox (but doesn't apply since this is native)
  • Version 0.22.0

Additional context
Perhaps #955 is related to this although I haven't looked into it. Reread the description for this, doesn't sound very related

A quick fix I applied locally to understand the bug is this in containers/area.rs. I'm not sure if this negatively affects other widgets or if any other widgets are affected by a similar bug

diff --git a/crates/egui/src/containers/area.rs b/crates/egui/src/containers/area.rs
index f493c20c..760ca141 100644
--- a/crates/egui/src/containers/area.rs
+++ b/crates/egui/src/containers/area.rs
@@ -271,7 +271,7 @@ impl Area {
         }
 
         // interact right away to prevent frame-delay
-        let move_response = {
+        let mut move_response = {
             let interact_id = layer_id.id.with("move");
             let sense = if movable {
                 Sense::click_and_drag()
@@ -321,6 +321,7 @@ impl Area {
                 ctx.constrain_window_rect_to_area(state.rect(), drag_bounds)
                     .left_top(),
             );
+            move_response = move_response.with_new_rect(Rect::from(state.rect()));
         }
 
         Prepared {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant