fix: disable code block language selector when editor is not editable #2351
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2156
Disable the language selector dropdown in code blocks when
editable={false}is set on the BlockNoteView.Rationale
As reported in #2156, when the editor is set to read-only mode (
editable={false}), the code block language selector dropdown remains interactive, allowing users to change the language. This is inconsistent with the expected behavior where all editing functionality should be disabled in read-only mode.Changes
editor.isEditablebefore registering the change event listener on the language selectorselect.disabled = truewhen the editor is in read-only modeImpact
editable={true}(default behavior)editable={false}, the language selector will be visually disabled and non-interactiveeditableare properly handled due to Tiptap'ssetEditable()triggering a re-render of block componentsTesting
editable={false}set on BlockNoteView - language selector is disablededitable- selector state updates correctly when toggling between editable and read-only modesScreenshots/Video
N/A
Checklist
Additional Notes