diff --git a/crates/yakui-core/src/layout/mod.rs b/crates/yakui-core/src/layout/mod.rs index 30e4df14..ac7e3007 100644 --- a/crates/yakui-core/src/layout/mod.rs +++ b/crates/yakui-core/src/layout/mod.rs @@ -175,7 +175,21 @@ impl LayoutDom { // If this node enabled clipping, the next node under that is the node // that clips this one. let clipped_by = if clipping_enabled { - self.clip_stack.iter().nth_back(2).copied() + let mut iter = self.clip_stack.iter(); + iter.next_back(); + iter.next_back(); + + let mut result = None; + while let Some(id) = iter.next_back().copied() { + match dom.get(id).unwrap().widget.flow() { + crate::Flow::Inline => { + result = Some(id); + break; + } + crate::Flow::Relative { .. } => (), + } + } + result } else { self.clip_stack.last().copied() };