Closed
Labels
bug:P2High: Core functionality significantly impacted.
Description
Describe the bug
In version 0.41.1 custom blocks directly reacted to changes to editor.isEditable and have rerendered.
But at the latest main version they don't (until they are interacted with which forces a rerender).
I suspect this is due to the fix (#2121) for (#2106).
To Reproduce
block-spec:
export const createTestBlock = createReactBlockSpec(
{
type: 'test',
propSchema: {
},
content: 'none',
},
{
render: (props) => {
return (
<div>{props.editor.isEditable ? 'editable' : 'readonly'}</div>
);
},
}
);editor:
export function Test() {
const [readonly, setReadonly] = useState(false);
const editor = useCreateBlockNote({
schema: BlockNoteSchema.create({
blockSpecs: {
test: createTestBlock(),
},
}),
initialContent: [
{
type: "test",
},
],
});
return <div>
<button onClick={() => setReadonly(r => !r)}>toggle</button>
<BlockNoteView editor={editor} editable={!readonly} />
</div>;
}Toggling the readonly button does not change block's content to readonly
Misc
- Node version:
- Package manager:
- Browser:
- I'm a sponsor and would appreciate if you could look into this sooner than later 💖
Metadata
Metadata
Assignees
Labels
bug:P2High: Core functionality significantly impacted.
Activity
nperez0111 commentedon Oct 28, 2025
Hi @kegesch, can you explain to me the use-case for this?
I'm uncertain how this code ever worked at all. I think it may have only been a fluke that it worked, I would expect this to be using the editor APIs not just be resetting the prop value
kegesch commentedon Oct 28, 2025
I use this in combination in with a button to make the editor non editable to avoid accidental changes, especially on mobile devices where touch gestures focus the editor or certain blocks.
But also to have the possibility to quickly re-enable the editing functionality to change the working document.
(Background: My app is a songwriting app and the readonly mode is for displaying the song for performances or practices)
Also using the editor API like
does not directly trigger a rerender.
nperez0111 commentedon Oct 29, 2025
OK, I understand.
I suspect that this will be a larger issue to address so it may take some time.
I think we will need to consider that changing the editor from editable to not should re-evaluate the entire editor & force the custom blocks to re-render.
I'm uncertain how this was working before, but I think it is more likely incidentally than calculated.
kegesch commentedon Oct 30, 2025
Okay, no problem.
I will use a context provider as a workaround in the mean time: