mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-14 10:39:32 +01:00
fix(story-mode): focus returns to the chip that opened the drawer; document this round's fields
- The final panel's chips were rebuilt on every redraw, so the chip that opened a drawer was gone by the time it closed and focus fell to the page body. Unchanged chips are now kept, and a trigger replaced anyway hands focus to the control that opens the same thing. - API reference: `older`, background Bash calls (`running`), `subject`, append hunks (`atEnd`), `files` resolved against the command's folder, test counts read before the output is cut, `roundsOk`, the `note` speaker and `noneWorked`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6a1bac6ebe
commit
d92e927184
3 files changed
+48
-18
No files matched your search
@@ -2358,19 +2358,24 @@ Object.assign(CodemanApp.prototype, {
|
||||
page.helpersRunning ? `, ${page.helpersRunning} still working` : ''
|
||||
}`,
|
||||
});
|
||||
chips.replaceChildren(
|
||||
...items.map((item) => {
|
||||
const li = document.createElement('li');
|
||||
const inner = document.createElement(item.open ? 'button' : 'span');
|
||||
if (item.open) {
|
||||
inner.type = 'button';
|
||||
inner.dataset.storyOpen = item.open;
|
||||
}
|
||||
inner.textContent = item.text;
|
||||
li.append(inner);
|
||||
return li;
|
||||
})
|
||||
);
|
||||
// Rebuilt only when they change: a chip that opened the drawer must still be there to take focus back.
|
||||
const chipsKey = JSON.stringify(items);
|
||||
if (chips.dataset.key !== chipsKey) {
|
||||
chips.dataset.key = chipsKey;
|
||||
chips.replaceChildren(
|
||||
...items.map((item) => {
|
||||
const li = document.createElement('li');
|
||||
const inner = document.createElement(item.open ? 'button' : 'span');
|
||||
if (item.open) {
|
||||
inner.type = 'button';
|
||||
inner.dataset.storyOpen = item.open;
|
||||
}
|
||||
inner.textContent = item.text;
|
||||
li.append(inner);
|
||||
return li;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2938,8 +2943,11 @@ Object.assign(CodemanApp.prototype, {
|
||||
st.drawerEl.hidden = true;
|
||||
st.root.classList.remove('has-drawer');
|
||||
st.drawerBody.replaceChildren();
|
||||
const back = st.drawerReturn;
|
||||
let back = st.drawerReturn;
|
||||
st.drawerReturn = null;
|
||||
// A control rebuilt while the drawer was open: its replacement opens the same thing.
|
||||
const key = back && !document.contains(back) ? back.dataset?.storyOpen : undefined;
|
||||
if (key) back = [...st.root.querySelectorAll('[data-story-open]')].find((n) => n.dataset.storyOpen === key);
|
||||
if (refocus && back && document.contains(back)) back.focus({ preventScroll: true });
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user