HarmonyOS 自定义Dialog上有自定义键盘,侧滑问题?

自定义对话框上有自定义键盘,键盘弹出时,快速侧滑两次,对话框不会关闭。

阅读 550
1 个回答

本地复现,现象是首次进入的时候弹出弹框第一次侧滑关闭键盘,第二次侧滑是返回了上一页,弹框依旧存在

滑动太快CustomDialogController没有监听到返回事件导致弹框没有在当前页面销毁

可以在aboutToDisappear或onPageHide回调中searchDialogController.close(),demo如下:

import { TradeStockSearchDialog } from './TradeStockSearchDialog';

@Entry
@Component
struct DialogPage {

  // 搜索对话框
  searchDialogController: CustomDialogController = new CustomDialogController({
    builder: TradeStockSearchDialog(),
    alignment: DialogAlignment.Bottom,
    customStyle: true,
  })

  build() {
    Column() {
      Button('弹窗')
        .onClick(() => {
          this.searchDialogController.open();
        })
    }
    .height('100%')
    .width('100%')
  }
  onCancel() {
    console.info('chen Callback when the first button is clicked')
  }
  onPageHide(): void {
    this.searchDialogController.close();
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进