diff --git a/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.cpp b/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.cpp index 770a4a549640b8a76a6fc53e4afbaf3a4f5bbc87..13b7ae5b8f1cacd3d451c2b2b4a67a4cb61e271b 100644 --- a/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.cpp +++ b/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.cpp @@ -796,11 +796,7 @@ bool MenuWrapperPattern::OnDirtyLayoutWrapperSwap(const RefPtr& d auto layoutProperty = menuPattern->GetLayoutProperty(); CHECK_NULL_RETURN(layoutProperty, false); isShowInSubWindow_ = layoutProperty->GetShowInSubWindowValue(true); - if (host->IsOnMainTree() && - ((IsContextMenu() && !IsHide()) || (((expandDisplay || isOpenMenu_) && isShowInSubWindow_) && !IsHide()) || - GetIsSelectOverlaySubWindowWrapper())) { - SetHotAreas(dirty); - } + SetHotAreas(dirty); MarkAllMenuNoDraggable(); MarkWholeSubTreeNoDraggable(GetPreview()); if (!GetHoverScaleInterruption()) { @@ -818,13 +814,9 @@ bool MenuWrapperPattern::IsNeedSetHotAreas(const RefPtr& layoutWr CHECK_NULL_RETURN(pipeline, false); auto theme = pipeline->GetTheme(); CHECK_NULL_RETURN(theme, false); - bool menuNotNeedsHotAreas = (layoutWrapper->GetAllChildrenWithBuild().empty() || !IsContextMenu()) && - !((theme->GetExpandDisplay() || isOpenMenu_) && isShowInSubWindow_); - if (menuNotNeedsHotAreas && !GetIsSelectOverlaySubWindowWrapper()) { - return false; - } - - return true; + auto container = AceEngine::Get().GetContainer(pipeline->GetInstanceId()); + CHECK_NULL_RETURN(container, false); + return host->IsOnMainTree() && !IsHide() && container->IsSubContainer(); } void MenuWrapperPattern::AddTargetWindowHotArea(std::vector& rects)