diff --git a/frameworks/bridge/common/dom/dom_node.cpp b/frameworks/bridge/common/dom/dom_node.cpp index 3ff14283..e3d01c7d 100644 --- a/frameworks/bridge/common/dom/dom_node.cpp +++ b/frameworks/bridge/common/dom/dom_node.cpp @@ -1438,6 +1438,10 @@ void DOMNode::UpdateBoxComponent() UpdateBoxBorder(borderStyle.border); } auto& backDecoration = declaration_->GetBackDecoration(); + if (!declaration_->HasBackGroundColor() && boxComponent_->GetBackDecoration() && + boxComponent_->HasBackgroundColor()) { + backDecoration->SetBackgroundColor(boxComponent_->GetBackDecoration()->GetBackgroundColor()); + } auto& backgroundStyle = static_cast(declaration_->GetStyle(StyleTag::COMMON_BACKGROUND_STYLE)); if (backgroundStyle.IsValid() && backgroundStyle.gradient.IsValid()) { diff --git a/frameworks/bridge/common/dom/dom_tab_bar.cpp b/frameworks/bridge/common/dom/dom_tab_bar.cpp index 63f7a4d3..7b3d274d 100644 --- a/frameworks/bridge/common/dom/dom_tab_bar.cpp +++ b/frameworks/bridge/common/dom/dom_tab_bar.cpp @@ -38,6 +38,7 @@ void DOMTabBar::InitializeStyle() } if (boxComponent_) { boxComponent_->SetColor(theme->GetBackgroundColor()); + boxComponent_->SetHasBackgroundColor(true); } auto paddingDimension = theme->GetPadding(); padding_ = Edge(paddingDimension.Value(), 0.0, paddingDimension.Value(), 0.0, paddingDimension.Unit()); diff --git a/frameworks/core/components/box/box_component.h b/frameworks/core/components/box/box_component.h index c0c70edb..6f46fdac 100644 --- a/frameworks/core/components/box/box_component.h +++ b/frameworks/core/components/box/box_component.h @@ -324,6 +324,16 @@ public: onLongPressId_ = onLongPressId; } + bool HasBackgroundColor() const + { + return hasBackgroundColor_; + } + + void SetHasBackgroundColor(bool hasBackgroundColor) + { + hasBackgroundColor_ = hasBackgroundColor; + } + private: RefPtr backDecoration_; RefPtr frontDecoration_; @@ -352,6 +362,7 @@ private: TextDirection inspectorDirection_ { TextDirection::LTR }; RefPtr> stateAttributeList_ = nullptr; EventMarker remoteMessageId_; + bool hasBackgroundColor_; }; } // namespace OHOS::Ace