Fix hovering over elements nested inside their parents

Julia and Conrad Irwin created

Co-Authored-By: Conrad Irwin <conrad@zed.dev>

Change summary

crates/collab_ui/src/collab_panel.rs |  2 -
crates/gpui/src/window.rs            | 34 ++++++++++++++---------------
2 files changed, 16 insertions(+), 20 deletions(-)

Detailed changes

crates/collab_ui/src/collab_panel.rs 🔗

@@ -2496,8 +2496,6 @@ impl CollabPanel {
                     .absolute()
                     .right(rems(0.))
                     .h_full()
-                    // HACK: Without this the channel name clips on top of the icons, but I'm not sure why.
-                    .z_index(10)
                     .child(
                         h_flex()
                             .h_full()

crates/gpui/src/window.rs 🔗

@@ -859,15 +859,14 @@ impl<'a> WindowContext<'a> {
 
             // At this point, we've established that this opaque layer is on top of the queried layer
             // and contains the position:
-            // - If the opaque layer is an extension of the queried layer, we don't want
-            // to consider the opaque layer to be on top and so we ignore it.
-            // - Else, we will bail early and say that the queried layer wasn't the top one.
-            let opaque_layer_is_extension_of_queried_layer = opaque_layer.len() >= layer.len()
-                && opaque_layer
-                    .iter()
-                    .zip(layer.iter())
-                    .all(|(a, b)| a.z_index == b.z_index);
-            if !opaque_layer_is_extension_of_queried_layer {
+            // If neither the opaque layer or the queried layer is an extension of the other then
+            // we know they are on different stacking orders, and return false.
+            let is_on_same_layer = opaque_layer
+                .iter()
+                .zip(layer.iter())
+                .all(|(a, b)| a.z_index == b.z_index);
+
+            if !is_on_same_layer {
                 return false;
             }
         }
@@ -908,15 +907,14 @@ impl<'a> WindowContext<'a> {
 
             // At this point, we've established that this opaque layer is on top of the queried layer
             // and contains the position:
-            // - If the opaque layer is an extension of the queried layer, we don't want
-            // to consider the opaque layer to be on top and so we ignore it.
-            // - Else, we will bail early and say that the queried layer wasn't the top one.
-            let opaque_layer_is_extension_of_queried_layer = opaque_layer.len() >= layer.len()
-                && opaque_layer
-                    .iter()
-                    .zip(layer.iter())
-                    .all(|(a, b)| a.z_index == b.z_index);
-            if !opaque_layer_is_extension_of_queried_layer {
+            // If neither the opaque layer or the queried layer is an extension of the other then
+            // we know they are on different stacking orders, and return false.
+            let is_on_same_layer = opaque_layer
+                .iter()
+                .zip(layer.iter())
+                .all(|(a, b)| a.z_index == b.z_index);
+
+            if !is_on_same_layer {
                 return false;
             }
         }