Editor doesn't switch back to visual editor if codeEditingEnabled
is false
#49211
Labels
[Feature] Code Editor
Handling the code view of the editing experience
[Type] Bug
An existing feature does not function as intended
Description
The block editor has a visual and a text mode (aka Code Editor). A user can freely switch between those and what a user has chosen is stored in local storage.
Text mode can be disabled using the
block_editor_settings_all
filter and thecodeEditingEnabled
setting.Using that filter you can also disable the code editor only under some specific conditions, e.g. for a specific post type.
The problem is that although this then disables the UI and keyboard shortcuts to switch, you can still end up in the text mode although you shouldn't be able to:
Step-by-step reproduction instructions
page
, e.g. like this:post
.page
.You can then still exit the Code editor by clicking the "Exit code editor" button (not using the keyboard shortcut) but you shouldn't even be able to end up here.
What I think should happen is that when opening a block editor where
codeEditingEnabled
is false the editor should automatically switch back to the visual editor or already get initialized in it.This is a quick fix the does this checking and switching back after initialization of the editor:
Screenshots, screen recording, code snippet
codeEditingEnabled.webm
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: