diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index e71c236dc7b..e22890562f6 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -4594,8 +4594,8 @@ int Tree::get_item_offset(TreeItem *p_item) const { return ofs; } - ofs += compute_item_height(it); - if (it != root || !hide_root) { + if ((it != root || !hide_root) && it->is_visible()) { + ofs += compute_item_height(it); ofs += theme_cache.v_separation; }