diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.cpp b/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.cpp index 192f8e6834e..798ece40435 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/text_field/text_field_model_ng.cpp @@ -738,6 +738,11 @@ void TextFieldModelNG::SetPadding(const NG::PaddingProperty& newPadding, Edge ol } NG::ViewAbstract::SetPadding(newPadding); ACE_UPDATE_PAINT_PROPERTY(TextFieldPaintProperty, PaddingByUser, newPadding); + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + pattern->SetIsInitTextRect(false); } void TextFieldModelNG::SetDefaultPadding() @@ -756,6 +761,9 @@ void TextFieldModelNG::SetDefaultPadding() paddings.right = NG::CalcLength(themePadding.Right().ConvertToPx()); ViewAbstract::SetPadding(paddings); ACE_UPDATE_PAINT_PROPERTY(TextFieldPaintProperty, PaddingByUser, paddings); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + pattern->SetIsInitTextRect(false); } void TextFieldModelNG::SetHoverEffect(HoverEffectType hoverEffect) @@ -1912,6 +1920,9 @@ void TextFieldModelNG::SetPadding(FrameNode* frameNode, NG::PaddingProperty& new CHECK_NULL_VOID(frameNode); NG::ViewAbstract::SetPadding(newPadding); ACE_UPDATE_NODE_PAINT_PROPERTY(TextFieldPaintProperty, PaddingByUser, newPadding, frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + pattern->SetIsInitTextRect(false); } RefPtr TextFieldModelNG::GetCustomKeyboard(FrameNode* frameNode) @@ -1972,6 +1983,9 @@ void TextFieldModelNG::SetBorderWidth(FrameNode* frameNode, NG::BorderWidthPrope CHECK_NULL_VOID(frameNode); NG::ViewAbstract::SetBorderWidth(frameNode, borderWidth); ACE_UPDATE_NODE_PAINT_PROPERTY(TextFieldPaintProperty, BorderWidthFlagByUser, borderWidth, frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + pattern->SetIsInitTextRect(false); } void TextFieldModelNG::SetBorderRadius(FrameNode* frameNode, NG::BorderRadiusProperty borderRadius) diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp index b5992f17fcb..db1dad0f254 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp @@ -2942,8 +2942,7 @@ void TextFieldPattern::OnModifyDone() SetShowError(); } // The textRect position can't be changed by only redraw. - if (CheckNeedMeasure(layoutProperty->GetPropertyChangeFlag()) && !HasInputOperation() && - (!HasFocus() || !initTextRect_) && isTextChangedAtCreation_) { + if (!initTextRect_) { textRect_.SetLeft(GetPaddingLeft() + GetBorderLeft()); textRect_.SetTop(GetPaddingTop() + GetBorderTop()); initTextRect_ = true; diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h index dfa2f4f4bb6..f4d4cd66044 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h +++ b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h @@ -1528,6 +1528,10 @@ public: const RefPtr& cleanNodeResponseArea); void StopContentScroll(); void UpdateContentScroller(const Offset& localOffset); + void SetIsInitTextRect(bool isInitTextRect) + { + initTextRect_ = isInitTextRect; + } protected: virtual void InitDragEvent();