Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/task-checkbox-disabled-after-editable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inkeep/open-knowledge-core": patch
---

Task-list checkboxes now stay clickable when an editor transitions from read-only to editable. The list-item NodeView set the checkbox's `disabled` state once at creation from `editor.isEditable`, but a `setEditable()` flip updates the view's editable flag without a document change, so ProseMirror never re-renders the NodeView and the stale `disabled` was never cleared. A checkbox created while the editor was read-only (for example, content loaded before the editor goes live) stayed permanently uncheckable. The NodeView now keeps `disabled` in sync with editability via the editor's `update` event (which `setEditable()` emits) and on every NodeView update.
14 changes: 10 additions & 4 deletions packages/core/src/extensions/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,19 @@ export const ListItemNode = Node.create({
let checkbox: HTMLInputElement | null = null;
const contentDiv = document.createElement('div');

const syncDisabled = () => {
if (checkbox) checkbox.disabled = !editor.isEditable;
};

if (node.attrs.checked !== null) {
checkboxLabel = document.createElement('label');
checkboxLabel.contentEditable = 'false';

checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.checked = !!node.attrs.checked;

if (!editor.isEditable) {
checkbox.disabled = true;
}
syncDisabled();
editor.on('update', syncDisabled);

checkbox.addEventListener('change', () => {
const pos = getPos();
Expand Down Expand Up @@ -368,11 +370,15 @@ export const ListItemNode = Node.create({
}
if (checkbox && updatedNode.attrs.checked !== null) {
checkbox.checked = !!updatedNode.attrs.checked;
checkbox.disabled = !editor.isEditable;
li.setAttribute('data-checked', String(!!updatedNode.attrs.checked));
}
node = updatedNode;
return true;
},
destroy() {
editor.off('update', syncDisabled);
},
};
};
},
Expand Down