Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style Book: keep browsing styles open when toggling on/off Style Book #59223

Closed
annezazu opened this issue Feb 20, 2024 · 2 comments · Fixed by #59261
Closed

Style Book: keep browsing styles open when toggling on/off Style Book #59223

annezazu opened this issue Feb 20, 2024 · 2 comments · Fixed by #59261
Assignees
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@annezazu
Copy link
Contributor

Using 6.5 beta 2, I noticed that if I were browsing style variations and turned on the style book, it would boot me out of browsing the style variations. I'd have to then re-enter style variations and continue selecting different options from there:

resets.browsing.styles.mov

This feels like a bug to me! To replicate:

  1. Open Styles
  2. Select "Browse styles"
  3. Select a different style
  4. Turn on the style book
  5. Notice you get booted out of your original spot
@annezazu annezazu added [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Feb 20, 2024
@annezazu annezazu moved this to ❓ Triage in WordPress 6.5 Editor Tasks Feb 20, 2024
@ramonjd
Copy link
Member

ramonjd commented Feb 21, 2024

Just to get started, I hacked something to get it working:

2024-02-21.11.33.06.mp4

The only snag is that the routing logic is complex.

Here's my hack for the record. I'm not proud of it, it's just for illustrative purposes 😄

THE HACK
	useEffect( () => {
		switch ( editorCanvasContainerView ) {
			case 'global-styles-revisions':
			case 'global-styles-revisions:style-book':
				goTo( '/revisions' );
				break;
			case 'global-styles-css':
				goTo( '/css' );
				break;
			case 'style-book':
				if ( path === '/revisions' ) {
					goTo( '/' );
				} else {
					goTo( path );
				}
				break;
			default:
				if ( path !== '/' && path !== '/revisions' ) {
					return;
				}
				goTo( '/' );
				break;
		}
	}, [ editorCanvasContainerView, goTo ] );

I'm adding notes here for the record.

What makes this exercise tricky is that there are two variables at play:

  1. The current path of the global styles sidebar - this value represents a navigation route and changes as we navigate down, up or between panels. E.g., path is / for the main global styles panel, /revisions for the global styles revisions, /typography/text for the global styles typography text settings and so on.
  2. editorCanvasContainerView - this value is meant to signify what's loaded in the editor canvas container, when not the current post. E.g., the style book.

Examples of how these two variables interact:

  1. when the canvas (editorCanvasContainerView) switches to global style revisions, we want to update the path to /revisions so the global styles revisions panel opens.
  2. when the canvas (editorCanvasContainerView) switches to style book, we don't care which global styles panel is open

I'm going to think about how to simplify all this and hopefully make it more robust.

@ramonjd
Copy link
Member

ramonjd commented Feb 21, 2024

Closing the loop here. I tried a few things and fell down a hole.

I'll try a "cleaner" version of the hack above.

@fabiankaegy fabiankaegy moved this from ❓ Triage to 📥 Todo in WordPress 6.5 Editor Tasks Feb 21, 2024
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Feb 22, 2024
@ramonjd ramonjd moved this from 📥 Todo to 🏗️ In Progress in WordPress 6.5 Editor Tasks Feb 22, 2024
@github-project-automation github-project-automation bot moved this from 🏗️ In Progress to ✅ Done in WordPress 6.5 Editor Tasks Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants