close
Skip to content

Add a responsiveEditingEnabled editor setting to hide the Responsive styles option - #80814

Merged
t-hamano merged 6 commits into
trunkfrom
add/responsive-editing-enabled-setting
Jul 29, 2026
Merged

Add a responsiveEditingEnabled editor setting to hide the Responsive styles option#80814
t-hamano merged 6 commits into
trunkfrom
add/responsive-editing-enabled-setting

Conversation

@t-hamano

@t-hamano t-hamano commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What?

Adds a responsiveEditingEnabled editor setting so that sites can hide the "Responsive styles" option from the device preview dropdown.

Why?

Feedback on the Call for Testing for responsive styling asked for a way to opt out of the feature.

How?

Adds a responsiveEditingEnabled editor setting, which can be set through the block_editor_settings_all filter. It follows the existing richEditingEnabled / codeEditingEnabled pattern.

The setting only hides the toggle. Responsive styles already stored in content, and the styles they output on the front end, are unaffected.

Testing Instructions

  1. On trunk, add a block and apply a style to the Mobile viewport only and save the post.

  2. Add the filter from the documentation to a plugin or your theme's functions.php:

    add_filter( 'block_editor_settings_all', function ( $settings ) {
    	$settings['responsiveEditingEnabled'] = false;
    	return $settings;
    } );
  3. Reload the editor and open the device preview dropdown. Confirm that "Responsive styles" is no longer listed and that the viewport options still work.

  4. Confirm the style applied in step 1 is still rendered in the editor and on the front end.

Repeat steps 3 and 4 in the Site Editor.

Use of AI Tools

Claude Code was used to write the implementation and documentation following my direction. I have reviewed and tested all of the changes.

Note

If this PR is merged, I plan to add code examples to the dev note to disable responsive editing.
https://make.wordpress.org/core/?p=124535&preview=1&_ppp=bb56023b02

Adds an editor setting, defaulting to `true`, that controls whether the
"Responsive styles" option is offered in the View menu. When a site sets
it to `false` through the `block_editor_settings_all` filter, the option
is not rendered and users cannot target style edits at a single viewport.

The setting follows the existing `richEditingEnabled` /
`codeEditingEnabled` pattern: the default lives in
`EDITOR_SETTINGS_DEFAULTS` and the only consumer, `PreviewDropdown`,
reads it from `getEditorSettings()`.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the [Package] Editor /packages/editor label Jul 29, 2026
@t-hamano t-hamano self-assigned this Jul 29, 2026
@t-hamano t-hamano added [Feature] Style States Related to block style states (currently viewport and pseudo-states) [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement. Backport to WP 7.1 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jul 29, 2026
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown

Size Change: +37 B (0%)

Total Size: 7.76 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 500 kB +37 B (+0.01%)

compressed-size-action

@t-hamano
t-hamano marked this pull request as ready for review July 29, 2026 01:23
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@andrewserong andrewserong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good and simple way to do it to me! I like the responsiveEditingEnabled name as it's consistent with some of the other settings, and this feels like an easy way for plugins or site owners to disable the responsive editing if they want to.

A couple of other things that I think is good about the approach:

  • It just hides the toggle, so responsive styles that exist in post content still work as before. This seems important if themes or templates wind up using responsive styles — it's just that an editor is prevented from making changes.
  • It also means that a plugin could disable based on user capability or other means so that perhaps an admin could make responsive styling changes, but regular authors etc maybe not, and so on

It does mean we'll need to keep this setting in mind for future changes to the UI, but I think that's also a good thing.

LGTM! 🚀

Comment thread packages/editor/src/store/defaults.js Outdated
* @property {boolean|Array} allowedBlockTypes Allowed block types
* @property {boolean} richEditingEnabled Whether rich editing is enabled or not
* @property {boolean} codeEditingEnabled Whether code editing is enabled or not
* @property {boolean} responsiveEditingEnabled Whether editing styles per viewport is enabled or not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally optional nit, to lead with the responsive name:

Suggested change
* @property {boolean} responsiveEditingEnabled Whether editing styles per viewport is enabled or not
* @property {boolean} responsiveEditingEnabled Whether responsive (per-viewport) style editing is enabled or not

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c6b9fa5

@ramonjd ramonjd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds a responsiveEditingEnabled editor setting so that sites can hide the "Responsive styles" option from the device preview dropdown.

This PR does what it says! I had a few questions around naming, and the JS dispatch to toggle off the preview dropdown.

Comment thread packages/editor/src/components/preview-dropdown/index.js
Comment thread docs/reference-guides/filters/editor-filters.md Outdated
Comment thread docs/how-to-guides/curating-the-editor-experience/disable-editor-functionality.md Outdated
Comment thread packages/editor/src/store/defaults.js
t-hamano and others added 4 commits July 29, 2026 11:51
Per review feedback, the description now starts with the setting's own
name so it reads consistently with the property it documents.

Co-Authored-By: Claude <noreply@anthropic.com>
The $context parameter was declared but never used in these snippets,
which also forced the accepted-args argument on add_filter(). Removing
both keeps the examples minimal and consistent with editor-filters.md.

Co-Authored-By: Claude <noreply@anthropic.com>
The default settings object listed responsiveEditingEnabled after
fontLibraryEnabled while the @Property docblock lists it before, making
the two orders diverge.

Co-Authored-By: Claude <noreply@anthropic.com>
The setting only hid the View menu option, so the site editor's Styles
page still exposed a viewport state selector, letting users add and edit
per-viewport global styles that the setting was meant to prevent.

Gating happens in GlobalStylesUIWrapper so both the editor sidebar and
the site editor Styles page are covered. Only viewport states are
withheld; pseudo states such as hover stay available.

Co-Authored-By: Claude <noreply@anthropic.com>
@t-hamano
t-hamano merged commit e438f35 into trunk Jul 29, 2026
49 of 56 checks passed
@t-hamano
t-hamano deleted the add/responsive-editing-enabled-setting branch July 29, 2026 04:13
@github-actions github-actions Bot added this to the Gutenberg 23.7 milestone Jul 29, 2026
@github-actions github-actions Bot removed the Backport to WP 7.1 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 29, 2026
gutenbergplugin pushed a commit that referenced this pull request Jul 29, 2026
…styles option (#80814)

* Add a responsiveEditingEnabled editor setting

Adds an editor setting, defaulting to `true`, that controls whether the
"Responsive styles" option is offered in the View menu. When a site sets
it to `false` through the `block_editor_settings_all` filter, the option
is not rendered and users cannot target style edits at a single viewport.

The setting follows the existing `richEditingEnabled` /
`codeEditingEnabled` pattern: the default lives in
`EDITOR_SETTINGS_DEFAULTS` and the only consumer, `PreviewDropdown`,
reads it from `getEditorSettings()`.

Co-Authored-By: Claude <noreply@anthropic.com>

* Add backport changelog

* Reword responsiveEditingEnabled JSDoc to lead with "responsive"

Per review feedback, the description now starts with the setting's own
name so it reads consistently with the property it documents.

Co-Authored-By: Claude <noreply@anthropic.com>

* Docs: Drop unused $context from block_editor_settings_all examples

The $context parameter was declared but never used in these snippets,
which also forced the accepted-args argument on add_filter(). Removing
both keeps the examples minimal and consistent with editor-filters.md.

Co-Authored-By: Claude <noreply@anthropic.com>

* Match responsiveEditingEnabled key order to the docblock

The default settings object listed responsiveEditingEnabled after
fontLibraryEnabled while the @Property docblock lists it before, making
the two orders diverge.

Co-Authored-By: Claude <noreply@anthropic.com>

* Hide the Global Styles viewport control when responsive editing is off

The setting only hid the View menu option, so the site editor's Styles
page still exposed a viewport state selector, letting users add and edit
per-viewport global styles that the setting was meant to prevent.

Gating happens in GlobalStylesUIWrapper so both the editor sidebar and
the site editor Styles page are covered. Only viewport states are
withheld; pseudo states such as hover stay available.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
@github-actions github-actions Bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Jul 29, 2026
@github-actions

Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.1 branch to get it included in the next release: 2095371

@t-hamano

Copy link
Copy Markdown
Contributor Author

I plan to add the following content to the dev note.

https://make.wordpress.org/core/?p=124535&preview=1&_ppp=bb56023b02


Opting out of responsive editing

Sites that need style changes to always apply to every viewport can turn off responsive editing with the responsiveEditingEnabled editor setting, which defaults to true:

add_filter( 'block_editor_settings_all', 'example_disable_responsive_editing' );

function example_disable_responsive_editing( $settings ) {
	$settings['responsiveEditingEnabled'] = false;
	return $settings;
}

When it is false, both entry points for choosing a viewport are removed: the "Responsive styles" toggle in the Editor's View menu, and the "Viewport" group in the "States" dropdown in Global Styles. Device previews still work, and pseudo states such as Hover remain available.

The setting governs the editing interface only. Responsive styles already saved in theme.json, in Global Styles, or in a block's style attribute are left untouched, and the media-query CSS described above is still generated for them, so existing content renders exactly as before both in the Editor and on the front end.

@t-hamano t-hamano added the has dev note when dev note is done (for upcoming WordPress release) label Jul 29, 2026
@andrewserong

Copy link
Copy Markdown
Contributor

I plan to add the following content to the dev note.

Nice one! Sorry to be nitpicky, there's a tiny bit of wording I'd tweak if you're up for it:

Sites that need style changes to always apply to every viewport can turn off responsive editing with the responsiveEditingEnabled editor setting, which defaults to true:

I'd possibly say instead

"Sites that need to prevent users from making viewport-based styling changes can turn off responsive style editing with the..."

So that it's clear it's about gating the the editing behaviour, not the styles output.

Up to you, though, otherwise that reads nicely to me!

@t-hamano

Copy link
Copy Markdown
Contributor Author

@andrewserong Thanks for the feedback! I have updated the content according to the feedback.

pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Jul 29, 2026
This updates the pinned commit hash of the Gutenberg repository from `4997026b75c922d8a6f77a03d72ed7cad04c7073` to `fd715a6833679d098d9fee84b642f8f1bc27341b`.

A full list of changes included in this commit can be found on GitHub: 
WordPress/gutenberg@4997026...fd715a6

- Update view config API versioning (WordPress/gutenberg#80319)
- Perf Tests: Fix 'Selecting blocks' metric reporting 0 ms (WordPress/gutenberg#80524)
- Notes: Register the inline note format at import time (WordPress/gutenberg#80576)
- Media: Stop forcing crossorigin on IMG tags in media templates (WordPress/gutenberg#80532)
- GradientPicker: select by slug so two presets sharing a gradient keep their identity (WordPress/gutenberg#80554)
- Media Editor: Show a loading state while the cropped file loads (WordPress/gutenberg#80460)
- Remove default paragraph from tab-panel template (WordPress/gutenberg#80565)
- Global Styles: Resolve link element styles in block inspector controls for blocks that are links (WordPress/gutenberg#80607)
- Media REST API: Backport sideload from url path upload size check (WordPress/gutenberg#80659)
- Rich text: remove tabIndex from editable elements again to fix shift+click selection (WordPress/gutenberg#80651)
- Gallery: make dynamic mode conversion a single undo level (WordPress/gutenberg#80665)
- Background image control: Remove duplicated focus ring (WordPress/gutenberg#80671)
- Detach core's note mention kses filter in the baseline strip test (WordPress/gutenberg#80656)
- wp-build: sync the page template preload field list with core-data (WordPress/gutenberg#80648)
- Read the contentEditable attribute in ownsSelection, not isContentEditable (WordPress/gutenberg#80549)
- Writing flow: extend block selections with shift+arrow when there is no native selection (WordPress/gutenberg#80687)
- Notes: Capture the target block before saving a block-level note (WordPress/gutenberg#80690)
- Theme JSON: Level block-level preset class specificity with :where() (WordPress/gutenberg#80657)
- Notes: Sync the sidebar selection to the inline marker under the caret (WordPress/gutenberg#80610)
- Writing flow: use isMultiSelecting for shift+click (WordPress/gutenberg#80286) (WordPress/gutenberg#80726)
- Block supports: Return from layout support before resolving global settings (WordPress/gutenberg#80771)
- Notes: Report save success consistently from note actions (WordPress/gutenberg#80748)
- Dynamic Gallery: Rename toolbar button to Detach and add a modal explaining what will happen (WordPress/gutenberg#80727) (WordPress/gutenberg#80774)
- ToolsPanel: Migrate styles to an SCSS Module (WordPress/gutenberg#80445) (WordPress/gutenberg#80800)
- Add a responsiveEditingEnabled editor setting to hide the Responsive styles option (WordPress/gutenberg#80814)
- iOS: remove jumping hack, add typewriter (WordPress/gutenberg#74596)
- Writing flow: stop the page scrolling on caret moves within blocks taller than the viewport (WordPress/gutenberg#80708)
- Global Styles: Put the inheritance UI behind a Gutenberg experiment (… (WordPress/gutenberg#80818)
- Notes: Cancel in-flight hover highlight when focus leaves a note thread (WordPress/gutenberg#80752)
- Block Editor: Try to fix typing performance regression (WordPress/gutenberg#80507)
- List Block: Preserve ordered type on indent (WordPress/gutenberg#75353)
- Make editableRoot a private block setting Symbol, not a public support (WordPress/gutenberg#80820)
- Fix cursor position during forward delete of empty blocks (WordPress/gutenberg#80827)
- Navigation: Fixes `aria-expanded` not updating on hover submenu inside overlay (WordPress/gutenberg#80828)
- Remove redundant @jest-environment jsdom pragma and lint against it (WordPress/gutenberg#80676)
- View config: reject shape-mismatched merges, define empty-array semantics, strip nulls from appended members (WordPress/gutenberg#80829)
- Editor: leave undo to the browser in fields that handle their own undo (WordPress/gutenberg#80768)
- Fix: New route-based admin pages are empty when no JS (WordPress/gutenberg#80839)

Props wildworks.
See #65529.

git-svn-id: https://develop.svn.wordpress.org/trunk@62896 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jul 29, 2026
This updates the pinned commit hash of the Gutenberg repository from `4997026b75c922d8a6f77a03d72ed7cad04c7073` to `fd715a6833679d098d9fee84b642f8f1bc27341b`.

A full list of changes included in this commit can be found on GitHub: 
WordPress/gutenberg@4997026...fd715a6

- Update view config API versioning (WordPress/gutenberg#80319)
- Perf Tests: Fix 'Selecting blocks' metric reporting 0 ms (WordPress/gutenberg#80524)
- Notes: Register the inline note format at import time (WordPress/gutenberg#80576)
- Media: Stop forcing crossorigin on IMG tags in media templates (WordPress/gutenberg#80532)
- GradientPicker: select by slug so two presets sharing a gradient keep their identity (WordPress/gutenberg#80554)
- Media Editor: Show a loading state while the cropped file loads (WordPress/gutenberg#80460)
- Remove default paragraph from tab-panel template (WordPress/gutenberg#80565)
- Global Styles: Resolve link element styles in block inspector controls for blocks that are links (WordPress/gutenberg#80607)
- Media REST API: Backport sideload from url path upload size check (WordPress/gutenberg#80659)
- Rich text: remove tabIndex from editable elements again to fix shift+click selection (WordPress/gutenberg#80651)
- Gallery: make dynamic mode conversion a single undo level (WordPress/gutenberg#80665)
- Background image control: Remove duplicated focus ring (WordPress/gutenberg#80671)
- Detach core's note mention kses filter in the baseline strip test (WordPress/gutenberg#80656)
- wp-build: sync the page template preload field list with core-data (WordPress/gutenberg#80648)
- Read the contentEditable attribute in ownsSelection, not isContentEditable (WordPress/gutenberg#80549)
- Writing flow: extend block selections with shift+arrow when there is no native selection (WordPress/gutenberg#80687)
- Notes: Capture the target block before saving a block-level note (WordPress/gutenberg#80690)
- Theme JSON: Level block-level preset class specificity with :where() (WordPress/gutenberg#80657)
- Notes: Sync the sidebar selection to the inline marker under the caret (WordPress/gutenberg#80610)
- Writing flow: use isMultiSelecting for shift+click (WordPress/gutenberg#80286) (WordPress/gutenberg#80726)
- Block supports: Return from layout support before resolving global settings (WordPress/gutenberg#80771)
- Notes: Report save success consistently from note actions (WordPress/gutenberg#80748)
- Dynamic Gallery: Rename toolbar button to Detach and add a modal explaining what will happen (WordPress/gutenberg#80727) (WordPress/gutenberg#80774)
- ToolsPanel: Migrate styles to an SCSS Module (WordPress/gutenberg#80445) (WordPress/gutenberg#80800)
- Add a responsiveEditingEnabled editor setting to hide the Responsive styles option (WordPress/gutenberg#80814)
- iOS: remove jumping hack, add typewriter (WordPress/gutenberg#74596)
- Writing flow: stop the page scrolling on caret moves within blocks taller than the viewport (WordPress/gutenberg#80708)
- Global Styles: Put the inheritance UI behind a Gutenberg experiment (… (WordPress/gutenberg#80818)
- Notes: Cancel in-flight hover highlight when focus leaves a note thread (WordPress/gutenberg#80752)
- Block Editor: Try to fix typing performance regression (WordPress/gutenberg#80507)
- List Block: Preserve ordered type on indent (WordPress/gutenberg#75353)
- Make editableRoot a private block setting Symbol, not a public support (WordPress/gutenberg#80820)
- Fix cursor position during forward delete of empty blocks (WordPress/gutenberg#80827)
- Navigation: Fixes `aria-expanded` not updating on hover submenu inside overlay (WordPress/gutenberg#80828)
- Remove redundant @jest-environment jsdom pragma and lint against it (WordPress/gutenberg#80676)
- View config: reject shape-mismatched merges, define empty-array semantics, strip nulls from appended members (WordPress/gutenberg#80829)
- Editor: leave undo to the browser in fields that handle their own undo (WordPress/gutenberg#80768)
- Fix: New route-based admin pages are empty when no JS (WordPress/gutenberg#80839)

Props wildworks.
See #65529.
Built from https://develop.svn.wordpress.org/trunk@62896


git-svn-id: http://core.svn.wordpress.org/trunk@62163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@tellthemachines

Copy link
Copy Markdown
Contributor

Thanks for sorting this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Style States Related to block style states (currently viewport and pseudo-states) has dev note when dev note is done (for upcoming WordPress release) [Package] Editor /packages/editor [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants