yangchenggong1_wd

fix:bug[17197] 搜索-取消清空搜索记录,不应弹出键盘

@@ -110,6 +110,10 @@ export struct SearchComponent { @@ -110,6 +110,10 @@ export struct SearchComponent {
110 this.searchHistoryData = SearcherAboutDataModel.getSearchHistoryData() 110 this.searchHistoryData = SearcherAboutDataModel.getSearchHistoryData()
111 } 111 }
112 112
  113 + stopInput(){
  114 + this.controller.stopEditing()
  115 + }
  116 +
113 build() { 117 build() {
114 Column() { 118 Column() {
115 this.searchInputComponent() 119 this.searchInputComponent()
@@ -117,7 +121,7 @@ export struct SearchComponent { @@ -117,7 +121,7 @@ export struct SearchComponent {
117 Scroll(this.scroller) { 121 Scroll(this.scroller) {
118 Column() { 122 Column() {
119 if(this.searchHistoryData!=null && this.searchHistoryData.length>0){ 123 if(this.searchHistoryData!=null && this.searchHistoryData.length>0){
120 - SearchHistoryComponent({ searchHistoryData: $searchHistoryData, onDelHistory: (): void => this.getSearchHistoryData(),onGetSearchRes: (item,index): void => this.getSearchHistoryResData(item,index) }) 124 + SearchHistoryComponent({ searchHistoryData: $searchHistoryData, onDelHistory: (): void => this.getSearchHistoryData(),onGetSearchRes: (item,index): void => this.getSearchHistoryResData(item,index),onCloseInput : (): void => this.stopInput() })
121 } 125 }
122 126
123 if(this.searchHistoryData.length>0){ 127 if(this.searchHistoryData.length>0){
@@ -257,7 +261,6 @@ export struct SearchComponent { @@ -257,7 +261,6 @@ export struct SearchComponent {
257 .textFont({ size: "27lpx", weight: "400lpx" }) 261 .textFont({ size: "27lpx", weight: "400lpx" })
258 // .defaultFocus(true) 262 // .defaultFocus(true)
259 .id("searchId") 263 .id("searchId")
260 - .focusable(true)  
261 .searchIcon({ 264 .searchIcon({
262 size:0 265 size:0
263 }) 266 })
@@ -8,11 +8,14 @@ import { MyCustomDialog } from '../reusable/MyCustomDialog' @@ -8,11 +8,14 @@ import { MyCustomDialog } from '../reusable/MyCustomDialog'
8 @Component 8 @Component
9 export struct SearchHistoryComponent{ 9 export struct SearchHistoryComponent{
10 @Link searchHistoryData:SearchHistoryItem[] 10 @Link searchHistoryData:SearchHistoryItem[]
  11 + onCloseInput?: () => void;
11 onDelHistory?: () => void; 12 onDelHistory?: () => void;
12 onGetSearchRes?: (item:string,index:number) => void; 13 onGetSearchRes?: (item:string,index:number) => void;
13 dialogController: CustomDialogController = new CustomDialogController({ 14 dialogController: CustomDialogController = new CustomDialogController({
14 builder: MyCustomDialog({ 15 builder: MyCustomDialog({
15 - cancel: this.onCancel, 16 + cancel: () => {
  17 + this.onCancel()
  18 + },
16 confirm: () => { 19 confirm: () => {
17 this.onAccept() 20 this.onAccept()
18 }, 21 },
@@ -33,6 +36,9 @@ export struct SearchHistoryComponent{ @@ -33,6 +36,9 @@ export struct SearchHistoryComponent{
33 } 36 }
34 37
35 onCancel() { 38 onCancel() {
  39 + if (this.onCloseInput !== undefined) {
  40 + this.onCloseInput()
  41 + }
36 console.info('Callback when the first button is clicked') 42 console.info('Callback when the first button is clicked')
37 } 43 }
38 44