From 4d6a09f33fcda311afda53b695a6cdb0b82da10d Mon Sep 17 00:00:00 2001 From: sunxuhui Date: Fri, 11 Jul 2025 17:01:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=B0=E5=A2=9E=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3anchorPosition=E5=9C=A8updateMenu=E4=B8=AD=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sunxuhui --- frameworks/core/components_ng/base/view_abstract.cpp | 7 ++----- test/unittest/core/base/view_abstract_test_ng.cpp | 4 ---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/frameworks/core/components_ng/base/view_abstract.cpp b/frameworks/core/components_ng/base/view_abstract.cpp index 11188a85208..4bbe926a215 100644 --- a/frameworks/core/components_ng/base/view_abstract.cpp +++ b/frameworks/core/components_ng/base/view_abstract.cpp @@ -4339,13 +4339,10 @@ int32_t ViewAbstract::UpdateMenu(const NG::MenuParam& menuParam, const RefPtr(wrapperPattern->GetTargetId()); CHECK_NULL_RETURN(target, ERROR_CODE_INTERNAL_ERROR); NG::OffsetF targetNodePosition = target->GetPositionToWindowWithTransform(); - auto pipelineContext = target->GetContext(); - CHECK_NULL_RETURN(pipelineContext, ERROR_CODE_INTERNAL_ERROR); - auto windowRect = pipelineContext->GetDisplayWindowRectInfo(); NG::OffsetF menuPosition = { menuParam.anchorPosition.GetX() + menuParam.positionOffset.GetX() + - targetNodePosition.GetX() + windowRect.Left(), + targetNodePosition.GetX(), menuParam.anchorPosition.GetY() + menuParam.positionOffset.GetY() + - targetNodePosition.GetY() + windowRect.Top() }; + targetNodePosition.GetY() }; menuProperty->UpdateMenuOffset(menuPosition); menuProperty->ResetMenuPlacement(); } diff --git a/test/unittest/core/base/view_abstract_test_ng.cpp b/test/unittest/core/base/view_abstract_test_ng.cpp index 1b7dbea200b..79856ec5784 100644 --- a/test/unittest/core/base/view_abstract_test_ng.cpp +++ b/test/unittest/core/base/view_abstract_test_ng.cpp @@ -2049,10 +2049,6 @@ HWTEST_F(ViewAbstractTestNg, UpdateMenu004, TestSize.Level1) auto menuItemPattern = menuItem->GetPattern(); menuItemPattern->expandingMode_ = SubMenuExpandingMode::STACK; EXPECT_EQ(ViewAbstract::UpdateMenu(menuParam, contentNode), ERROR_CODE_NO_ERROR); - - menuParam.isAnchorPosition = true; - menuParam.anchorPosition = {10.0, 10.0}; - EXPECT_EQ(ViewAbstract::UpdateMenu(menuParam, contentNode), ERROR_CODE_NO_ERROR); } /** -- Gitee