GithubHelp home page GithubHelp logo

Comments (14)

youknowriad avatar youknowriad commented on August 16, 2024 1

@ramonjd as an escape hatch, there's already a way to exit this using the command palette. But I'm hoping we can land #61579 to fix this entirely.

from gutenberg.

draganescu avatar draganescu commented on August 16, 2024 1

I can imagine some folks might be find themselves unable to revert to "Distraction" mode ๐Ÿ˜„ I guess this bug has made it to Core a while back.

@ramonjd this has not been shipped in core, itโ€™s been shipped with Gutenberg releases. #61579 will fix this when merged and be back ported to WP.

from gutenberg.

Mamaduka avatar Mamaduka commented on August 16, 2024

cc @youknowriad, @draganescu

from gutenberg.

youknowriad avatar youknowriad commented on August 16, 2024

Thanks for catching this. I tried looking and it's a bit challenging. The distraction free "hover" animation is split into two parts:

  • the first hover event handler animates the hub (so the hub needs to be 100% wide)
  • the second hover event handler animates the header itself

The problem now is that the header is not rendered within the hub anymore, the hover event of the header is not triggered anymore. It seems there's no way to trigger two hover events for elements that are not within each other (one covering the other).

I see two options:

  • A hack: simulate a hover event manually on the header when hovering the hub (dispatchEvent)
  • A better fix but requires some design changes: Render the hub within the header (rather than keep it on top of the header but visually make it look like it's in the header). The animation when entering and exiting the "edit" mode for the hub becomes harder to achieve.

from gutenberg.

draganescu avatar draganescu commented on August 16, 2024

@jeryj I think this is worth a look from you as you've been improving this animation a bit in the past as well. Maybe you have more to add to what Riad described above.

from gutenberg.

jeryj avatar jeryj commented on August 16, 2024

I found a way to share the header animation state via a context and using that variant name to set the animation of the other components. It's far from finished, but it may be a way forward with enough tweaking to be able to use one div to set the animation variant and pass it to the others: #60916

What do you think @youknowriad?

from gutenberg.

youknowriad avatar youknowriad commented on August 16, 2024

For me it's still a hack. The interface skeleton's API has been changed to receive a variant prop for the header? It doesn't make much sense in terms of API for that component.

I'm of the opinion that we should do my proposed hack 1 temporarily and try to implement 2 longer term. In the post editor the "toggle" (hub) or whatever is part of the header, it should be the same in the site editor.

from gutenberg.

jeryj avatar jeryj commented on August 16, 2024

The interface skeleton's API has been changed to receive a variant prop for the header? It doesn't make much sense in terms of API for that component.

It's less about the API of how things are passed around. I wasn't focused on that. I more mean the design of using consistent variant names and using those variant names to keep all the animation states in line. So, for your recommended hack:

A hack: simulate a hover event manually on the header when hovering the hub (dispatchEvent)

Rather than simulate a hover event manually on the header, set an animation state of a variant name somewhere that can be read by whatever wants to use it.

from gutenberg.

youknowriad avatar youknowriad commented on August 16, 2024

Rather than simulate a hover event manually on the header, set an animation state of a variant name somewhere that can be read by whatever wants to use it.

Yeah I understand and could be fine as a temporary solution but I just don't see why the header animation need to be set on the "layout" hub component. Why would the "layout" of the site editor pass a variation name to the header of a specific page/route of the site editor. The layout shouldn't even know about the registered routes/pages. Ultimately the "shell" of the site editor and the routes/pages will be in completely different packages probably as we'll have other pages in WP-Admin that may use the same "shell".

from gutenberg.

jeryj avatar jeryj commented on August 16, 2024

I just don't see why the header animation need to be set on the "layout" hub component.

It wouldn't need to be set there. The example I showed is a proof of concept of how setting and reading a variant name might be a good way forwards so we can trigger multiple layers of animations consistently from wherever makes the most sense. I'm not committed to this approach, fwiw. Trying to provide more options that could work.

Render the hub within the header (rather than keep it on top of the header but visually make it look like it's in the header). The animation when entering and exiting the "edit" mode for the hub becomes harder to achieve.

If we go this route, we'd need to make sure the semantics of the page are correct and focus is handled between elements disappearing/appearing.

from gutenberg.

draganescu avatar draganescu commented on August 16, 2024

๐Ÿ‘‹๐Ÿป given that this is a shipped bug and it's also a bug that prevents action (user is stuck in distraction free, user is stuck with no save/publish) unless they visit the post editor to exit DFM, I would vote to land a hack if the proper solution is too convoluted.

from gutenberg.

stokesman avatar stokesman commented on August 16, 2024

In anyone subscribed here has some availability you may wish to test the hack I made at #61874 as that fixes this in my testing. I'd like to think it may not be a hack but I donโ€™t comprehend its potential impacts.

UPDATE: Closed that PR. I donโ€™t think we can consider it and its primary purpose wasnโ€™t to fix this issueโ€”it just happened to. The primary thing it meant to fix is better done by #61882 (which unfortunately didnโ€™t impact this).

from gutenberg.

ramonjd avatar ramonjd commented on August 16, 2024

Just noticed this while testing something else.

Is there any way to provide an intuitive and accessible exit for users who activate distraction free mode?

Currently the only way I can find is to use the control panel (Cmd+K) and select Exit Distraction Free.

given that this is a shipped bug and it's also a bug that prevents action (user is stuck in distraction free, user is stuck with no save/publish) unless they visit the post editor to exit DFM, I would vote to land a hack if the proper solution is too convoluted.

๐Ÿ’ฏ

I can imagine some folks might be find themselves unable to revert to "Distraction" mode ๐Ÿ˜„ I guess this bug has made it to Core a while back.

I can only speak for myself, but it's pretty frustrating.

Even a persistent snackbar with "Exit" or "Undo" would help, or removing the feature entirely from the Site Editor. Example:

diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js
index d934436800..94643aaaf2 100644
--- a/packages/editor/src/store/actions.js
+++ b/packages/editor/src/store/actions.js
@@ -15,6 +15,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
 import { applyFilters } from '@wordpress/hooks';
 import { store as preferencesStore } from '@wordpress/preferences';
 import { __ } from '@wordpress/i18n';
+import { getPath } from '@wordpress/url';
 
 /**
  * Internal dependencies
@@ -737,6 +738,9 @@ export const toggleDistractionFree =
 		const isDistractionFree = registry
 			.select( preferencesStore )
 			.get( 'core', 'distractionFree' );
+		const isSiteEditor = getPath( window.location.href )?.includes(
+			'site-editor.php'
+		);
 		if ( isDistractionFree ) {
 			registry
 				.dispatch( preferencesStore )
@@ -764,9 +768,17 @@ export const toggleDistractionFree =
 					{
 						id: 'core/editor/distraction-free-mode/notice',
 						type: 'snackbar',
+						/*
+						 * Persist the snackbar in the case of Distraction Free mode.
+						 * There is a bug where the header is not visible in the Site Editor.
+						 * See: https://github.com/WordPress/gutenberg/issues/60875
+						 */
+						explicitDismiss: isSiteEditor && ! isDistractionFree,
 						actions: [
 							{
-								label: __( 'Undo' ),
+								label: isDistractionFree
+									? __( 'Undo' )
+									: __( 'Exit' ),
 								onClick: () => {
 									registry.batch( () => {
 										registry


In action:

2024-06-05.15.37.16.mp4

I can get a PR up if folks agree it's a decent interim move. I'd also look into adding a prop to the snackbar component to explicitly hide the close button.

from gutenberg.

ramonjd avatar ramonjd commented on August 16, 2024

Ah gotcha, thanks for the feedback @draganescu and @youknowriad ๐Ÿ™‡๐Ÿป

from gutenberg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.