From 93c8cac5bc8e8e75541750daa53e8aa9bb13465a Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 8 Sep 2026 15:48:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(tab):=20TabPanel=E5=88=A0tab/=E5=BC=80tab?= =?UTF-8?q?=E4=B8=A4bug=E2=80=94=E2=80=94=E2=91=A0=E5=88=A0=E5=BD=93?= =?UTF-8?q?=E5=89=8Dtab=E5=86=85=E5=AE=B9=E4=B8=8D=E6=B8=85+=E4=B8=8D?= =?UTF-8?q?=E5=9B=9E=E5=88=87:Toolbar.remove=5Fitem=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84unselect=5Fitem=E6=8A=9BTyp?= =?UTF-8?q?eError=E8=87=B4dispatch('remove')=E6=B0=B8=E8=BF=9C=E5=88=B0?= =?UTF-8?q?=E4=B8=8D=E4=BA=86tab=5Fremoved(Layout=E8=A1=A5unselect=5Fitem;?= =?UTF-8?q?tab=5Fremoved=E8=A1=A5items=E7=A7=BB=E9=99=A4/content=20destroy?= =?UTF-8?q?/=E6=97=A0tab=E6=B8=85=E7=A9=BA);=E2=91=A1=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=96=B0=E5=A2=9Etab=E9=AB=98=E4=BA=AE=E4=B8=8D=E5=88=87:creat?= =?UTF-8?q?eTool=E6=98=AFasync,=E5=90=8C=E6=AD=A5toolbar.click=E6=97=B6?= =?UTF-8?q?=E6=96=B0=E6=8C=89=E9=92=AE=E6=9C=AA=E8=BF=9BtoolList=E7=A9=BA?= =?UTF-8?q?=E8=BD=AC(open=5Ftab=E6=94=B9await=20add=5Ftab=E5=90=8E?= =?UTF-8?q?=E5=86=8Dclick);=E5=88=A0tab=E5=9B=9E=E5=88=87=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=3D=E8=AE=BF=E9=97=AE=E5=8E=86=E5=8F=B2=E6=9C=80?= =?UTF-8?q?=E8=BF=91tab(=5Fpush=5Ftab=5Fhistory),=E9=9D=9E=E5=9B=BA?= =?UTF-8?q?=E5=AE=9Afirst(2026-09-08=E7=94=A8=E6=88=B7=E6=8A=A5bug,playwri?= =?UTF-8?q?ght=E6=9C=AC=E5=9C=B0=E5=AE=9E=E6=B5=8B=E4=BF=AE=E5=A4=8D+?= =?UTF-8?q?=E8=BE=B9=E7=BC=98=E7=94=A8=E4=BE=8B=E8=BF=87)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bricks/layout.js | 7 ++++++ bricks/tab.js | 60 ++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/bricks/layout.js b/bricks/layout.js index 4fe66b9..41e147c 100644 --- a/bricks/layout.js +++ b/bricks/layout.js @@ -63,6 +63,13 @@ bricks.Layout = class extends bricks.JsWidget { this.selected_item = w; this.selected_item.selected(true); } + unselect_item(w){ + // 与 select_item 对称:仅当 w 是当前选中项时取消选中 + if (this.selected_item === w){ + w.selected(false); + this.selected_item = null; + } + } select_default_item(){ if (!this.keyselectable) return; var w = this.children[0]; diff --git a/bricks/tab.js b/bricks/tab.js index 3e24ef1..1949cc9 100644 --- a/bricks/tab.js +++ b/bricks/tab.js @@ -190,6 +190,7 @@ bricks.TabPanel = class extends bricks.Layout { } this.content_buffer[tdesc.name] = w; } + this._push_tab_history(tdesc.name); this.cur_tab_name = tdesc.name; this.switch_content(w); return; @@ -216,8 +217,10 @@ bricks.TabPanel = class extends bricks.Layout { if (w && this.cur_tab_name === desc.name) this.switch_content(w); } // 动态打开 tab:已存在则切换(默认刷新内容,desc.refresh===false 用缓存), - // 不存在则新增。同步返回:立即切换+高亮,content 异步加载。 - open_tab(desc){ + // 不存在则新增。content 异步加载不阻塞;新增时等 createTool 真正建出按钮 + // 再 toolbar.click —— createTool 是 async(await widgetBuild),若同步 click, + // 新按钮还没进 toolList,click 空转 → active 高亮不切换(2026-09-08 bugfix)。 + async open_tab(desc){ var existing = null; for (var i=0;i=0;i--){ + for (var j=0;j