!48689 修复option打开2次text文本长度发生变化的问题

Merge pull request !48689 from FredTT/temp1116
This commit is contained in:
openharmony_ci 2024-11-16 12:19:53 +00:00 committed by Gitee
commit 3e1a891f33
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 56 additions and 3 deletions

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OPTION_OPTION_ROW_PATTERN_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OPTION_OPTION_ROW_PATTERN_H
#include <optional>
#include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h"
namespace OHOS::Ace::NG {
class ACE_EXPORT OptionRowLayoutAlgorithm : public LinearLayoutAlgorithm {
DECLARE_ACE_TYPE(OptionRowLayoutAlgorithm, LinearLayoutAlgorithm);
public:
OptionRowLayoutAlgorithm() = default;
~OptionRowLayoutAlgorithm() override = default;
void Measure(LayoutWrapper* layoutWrapper) override {};
ACE_DISALLOW_COPY_AND_MOVE(OptionRowLayoutAlgorithm);
};
class OptionRowPattern : public LinearLayoutPattern {
DECLARE_ACE_TYPE(OptionRowPattern, LinearLayoutPattern);
public:
OptionRowPattern() : LinearLayoutPattern(false) {};
~OptionRowPattern() override = default;
RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override
{
return MakeRefPtr<OptionRowLayoutAlgorithm>();
}
ACE_DISALLOW_COPY_AND_MOVE(OptionRowPattern);
};
} // namespace OHOS::Ace::NG
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OPTION_OPTION_PATTERN_H

View File

@ -16,6 +16,7 @@
#include "base/i18n/localization.h"
#include "core/components_ng/pattern/menu/menu_item/menu_item_pattern.h"
#include "core/components_ng/pattern/option/option_row_pattern.h"
#include "core/components_ng/pattern/security_component/paste_button/paste_button_common.h"
#include "core/components_ng/pattern/security_component/paste_button/paste_button_model_ng.h"
#include "core/components_ng/pattern/security_component/security_component_pattern.h"
@ -248,7 +249,7 @@ RefPtr<FrameNode> OptionView::CreateMenuOption(bool optionsHasIcon, std::vector<
auto option = Create(index);
CHECK_NULL_RETURN(option, nullptr);
auto row = FrameNode::CreateFrameNode(V2::ROW_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
AceType::MakeRefPtr<LinearLayoutPattern>(false));
AceType::MakeRefPtr<OptionRowPattern>());
#ifdef OHOS_PLATFORM
constexpr char BUTTON_PASTE[] = "textoverlay.paste";
@ -269,7 +270,7 @@ RefPtr<FrameNode> OptionView::CreateMenuOption(bool optionsHasIcon, const Option
auto option = Create(index);
CHECK_NULL_RETURN(option, nullptr);
auto row = FrameNode::CreateFrameNode(V2::ROW_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
AceType::MakeRefPtr<LinearLayoutPattern>(false));
AceType::MakeRefPtr<OptionRowPattern>());
#ifdef OHOS_PLATFORM
constexpr char BUTTON_PASTE[] = "textoverlay.paste";
@ -289,7 +290,7 @@ RefPtr<FrameNode> OptionView::CreateSelectOption(const SelectParam& param, int32
LOGI("create option value = %s", param.text.c_str());
auto option = Create(index);
auto row = FrameNode::CreateFrameNode(V2::ROW_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),
AceType::MakeRefPtr<LinearLayoutPattern>(false));
AceType::MakeRefPtr<OptionRowPattern>());
row->MountToParent(option);
auto pattern = option->GetPattern<MenuItemPattern>();