fix(popup): 新建知识库弹窗点击即关闭 + Cancel 按钮无法关闭弹窗

根因(核实 bricks/popup.js 源码):
1. popup_options 显式写了 auto_dismiss:true,Popup 构造时把 click 绑到整个 bricks.Body,
   而 click_outside 只判断 event.target != this.dom_element(无子树 contains 判定),
   点击弹窗内任何子元素(输入框/下拉/按钮)都命中 → 立即 dismiss。改为 auto_dismiss:false。
2. 加 dismiss_events:['cancel','submited'] 让 Form 的取消/提交完成关闭弹窗。
   但 set_dismiss_events 只绑 load_content 返回的根 widget,而 dispatch 用
   new Event() 不冒泡(bubbles:false) —— 原根节点是 VBox、事件由子 Form 发出,绑不上。
   故把 Form 提为 new_kb_form.ui 根 widget,标题改用 Form 自带 title 选项。
   (title 不是 Popup 的合法 option,仅 PopupWindow/Form 支持)
This commit is contained in:
ymq 2026-08-25 16:05:57 +08:00
parent 51c9968093
commit f2afaa82e8
2 changed files with 18 additions and 19 deletions

View File

@ -63,7 +63,11 @@
"actiontype": "urlwidget",
"target": "Popup",
"popup_options": {
"auto_dismiss": true
"auto_dismiss": false,
"dismiss_events": ["cancel", "submited"],
"movable": true,
"width": "34%",
"height": "auto"
},
"options": {
"url": "{{entire_url('./new_kb_form.ui')}}"

View File

@ -1,24 +1,19 @@
{
"widgettype": "VBox",
"options": {"padding": "16px", "spacing": "12px"},
"subwidgets": [
{"widgettype": "Text", "options": {"text": "新建知识库", "cfontsize": 18, "fontWeight": "bold"}},
{
"widgettype": "Form",
"id": "kb_form",
"options": {
"cols": 1,
"fields": [
{"name": "name", "label": "名称", "uitype": "str", "required": true},
{"name": "description", "label": "描述", "uitype": "text"},
{"name": "embedding_type", "label": "向量引擎", "uitype": "code", "value": "clip-vith14", "dataurl": "{{entire_url('./embedding_options.dspy')}}"}
]
}
}
],
"widgettype": "Form",
"id": "kb_form",
"options": {
"cols": 1,
"title": "新建知识库",
"padding": "16px",
"fields": [
{"name": "name", "label": "名称", "uitype": "str", "required": true},
{"name": "description", "label": "描述", "uitype": "text"},
{"name": "embedding_type", "label": "向量引擎", "uitype": "code", "value": "clip-vith14", "dataurl": "{{entire_url('./embedding_options.dspy')}}"}
]
},
"binds": [
{
"wid": "kb_form",
"wid": "self",
"event": "submit",
"actiontype": "urlwidget",
"target": "app.rag_main_content",