Fix plus button disappearing on cancel.

This commit is contained in:
Chris McCormick 2026-01-04 17:08:45 +08:00
parent f61007cfb6
commit bf82427ebb

View file

@ -988,7 +988,7 @@ chmod 755 kbtd
$(`#${containerId}`).appendChild(clone);
}
function createAddForm(placeholder, onSubmit) {
function createAddForm(placeholder, onSubmit, onCancel) {
const input = h('input', { type: 'text', placeholder });
const form = h('div', { className: 'add-card-form' }, input);
@ -1012,7 +1012,10 @@ chmod 755 kbtd
h('button', { textContent: 'Add', onclick: handleSubmit }),
h('button', {
textContent: 'Cancel',
onclick: () => form.hide()
onclick: () => {
form.hide();
if (onCancel) onCancel();
}
})
);
@ -2001,12 +2004,6 @@ chmod 755 kbtd
ondragleave: handleDragLeave
}, ...cardElements);
const addCardForm = createAddForm('Card text...', async (text) => {
await createCard(colIndex, text);
addCardForm.hide();
addCardBtn.style.display = '';
});
const addCardBtn = h('button', {
className: 'add-card-btn',
textContent: '+',
@ -2017,6 +2014,14 @@ chmod 755 kbtd
}
});
const addCardForm = createAddForm('Card text...', async (text) => {
await createCard(colIndex, text);
addCardForm.hide();
addCardBtn.style.display = '';
}, () => {
addCardBtn.style.display = '';
});
return h('div', {
className: 'column',
dataset: { colIndex }