fix: keep session picker focus separate · openclaw/openclaw@7e12370
steipete
·
2026-05-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -105,29 +105,11 @@ function requestHostUpdate(state: AppViewState) {
|
105 | 105 | (state as AppViewState & { requestUpdate?: () => void }).requestUpdate?.(); |
106 | 106 | } |
107 | 107 | |
108 | | -function focusChatSessionPickerSearch(state: AppViewState, surface: ChatSessionSelectSurface) { |
109 | | -const updateComplete = (state as AppViewState & { updateComplete?: Promise<unknown> }) |
110 | | -.updateComplete; |
111 | | -const focus = () => { |
112 | | -document |
113 | | -.querySelector<HTMLInputElement>( |
114 | | -`[data-chat-session-picker-search="true"][data-chat-session-picker-search-surface="${surface}"]`, |
115 | | -) |
116 | | -?.focus(); |
117 | | -}; |
118 | | -if (updateComplete) { |
119 | | -void updateComplete.then(focus); |
120 | | -return; |
121 | | -} |
122 | | -setTimeout(focus, 0); |
123 | | -} |
124 | | - |
125 | 108 | function openChatSessionPicker(state: AppViewState, surface: ChatSessionSelectSurface) { |
126 | 109 | state.chatSessionPickerOpen = true; |
127 | 110 | state.chatSessionPickerSurface = surface; |
128 | 111 | state.chatSessionPickerError = null; |
129 | 112 | requestHostUpdate(state); |
130 | | -focusChatSessionPickerSearch(state, surface); |
131 | 113 | } |
132 | 114 | |
133 | 115 | function closeChatSessionPicker(state: AppViewState) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1348,7 +1348,7 @@ describe("chat session controls", () => {
|
1348 | 1348 | } |
1349 | 1349 | }); |
1350 | 1350 | |
1351 | | -it("focuses the inline search for the active picker surface", async () => { |
| 1351 | +it("keeps session trigger focus separate from inline search focus", async () => { |
1352 | 1352 | const { state } = createChatHeaderState(); |
1353 | 1353 | const mobileContainer = document.createElement("div"); |
1354 | 1354 | const desktopContainer = document.createElement("div"); |
@@ -1369,7 +1369,13 @@ describe("chat session controls", () => {
|
1369 | 1369 | expect( |
1370 | 1370 | mobileContainer.querySelector('input[data-chat-session-picker-search="true"]'), |
1371 | 1371 | ).toBeTruthy(); |
| 1372 | +expect(state.chatSessionPickerOpen).toBe(true); |
| 1373 | +expect(document.activeElement).not.toBe(desktopInput); |
| 1374 | + |
| 1375 | +desktopInput!.focus(); |
1372 | 1376 | await vi.waitFor(() => expect(document.activeElement).toBe(desktopInput)); |
| 1377 | +expect(state.chatSessionPickerOpen).toBe(true); |
| 1378 | +expect(state.chatSessionPickerSurface).toBe("desktop"); |
1373 | 1379 | } finally { |
1374 | 1380 | render(html``, mobileContainer); |
1375 | 1381 | render(html``, desktopContainer); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。