fix(skills): keep edit mode open on outside-the-textarea click (#4011)

Clicking the card body outside the edit <textarea> bubbled to the card's
click handler and collapsed the card, silently discarding unsaved skill
edits (issue #4002). The textarea's own stopPropagation only shields
clicks landing on it. Bail out of the card click handler while a
.skill-md-editor is present so the card only leaves edit mode via Save
(Cancel button is handled separately by #3580). Mirrors the same guard
into the built-in capability card, which shared the bug.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Max Hsu
2026-06-15 19:31:11 +08:00
committed by GitHub
parent 2adae2bbba
commit 172a8ea7b0
2 changed files with 62 additions and 0 deletions
+6
View File
@@ -514,6 +514,8 @@ function _buildBuiltinCards() {
card.addEventListener('click', (e) => {
if (e.target.closest('button, input, textarea')) return;
// Editing in progress → don't collapse on an outside-the-textarea click.
if (card.querySelector('.skill-md-editor')) return;
_expandBuiltinCard(card, b.name);
});
return card;
@@ -786,6 +788,10 @@ function renderSkillsList() {
card.addEventListener('click', (e) => {
if (card._suppressNextClick) { card._suppressNextClick = false; return; }
if (e.target.closest('button, input, textarea')) return;
// While editing, a click on the card body (outside the textarea) must
// NOT collapse the card — that silently discards unsaved edits. Only
// Save/Cancel exit edit mode.
if (card.querySelector('.skill-md-editor')) return;
if (_selectMode) {
const cb = card.querySelector('.skill-select-cb');
if (cb) { cb.checked = !cb.checked; cb.dispatchEvent(new Event('change')); }