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

Nonfatal error navigating Site editor in narrow viewports #68929

Open
3 of 6 tasks
stokesman opened this issue Jan 29, 2025 · 3 comments · May be fixed by #68907
Open
3 of 6 tasks

Nonfatal error navigating Site editor in narrow viewports #68929

stokesman opened this issue Jan 29, 2025 · 3 comments · May be fixed by #68907
Labels
Mobile Web Viewport sizes for mobile and tablet devices [Package] Edit Site /packages/edit-site [Type] Bug An existing feature does not function as intended

Comments

@stokesman
Copy link
Contributor

Description

In a narrow viewport (< 783px) in the Site editor, drilling down to a sub menu causes an error message in the console. I expect there to be no errors.

I'm not sure when this was introduced and it’s a pretty harmless thing. From what I can tell the only consequence besides console errors would be that the forward/back animations would not work. It’s a moot point for now because the nav immediately gets removed and there’s no chance to see an animation anyway.

Step-by-step reproduction instructions

  1. Open the Site editor in a narrow viewport (< 783px)
  2. Click a menu item that has a sub-menu
  3. Check the console and see the error

Screenshots, screen recording, code snippet

site-editor-narrow-viewport-nav-error.mp4

Environment info

  • WordPress 6.7.1 with Gutenberg plugin from trunk
  • Chrome
  • macOS

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@stokesman stokesman added [Package] Edit Site /packages/edit-site [Type] Bug An existing feature does not function as intended labels Jan 29, 2025
@stokesman
Copy link
Contributor Author

stokesman commented Jan 29, 2025

I slapped together a PR for this but left it drafted in case someone has a better idea. I’m pretty sure a simpler solution is:

diff --git a/packages/edit-site/src/components/sidebar-navigation-item/index.js b/packages/edit-site/src/components/sidebar-navigation-item/index.js
index 4bde94dcbb..1665a105b4 100644
--- a/packages/edit-site/src/components/sidebar-navigation-item/index.js
+++ b/packages/edit-site/src/components/sidebar-navigation-item/index.js
@@ -45,7 +45,7 @@ export default function SidebarNavigationItem( {
 		} else if ( to ) {
 			e.preventDefault();
 			history.navigate( to );
-			navigate( 'forward', `[id="${ uid }"]` );
+			navigate?.( 'forward', `[id="${ uid }"]` );
 		}
 	}
 	const linkProps = useLink( to );

It’s like ignoring the problem but maybe that’s fine for the time being. I think eventually progress toward #60847 will entail a more proper resolution.

@t-hamano
Copy link
Contributor

I remembered reporting this same error in the past: #67460

The cause of the problem appears to be explained here: #67467 (comment)

Either way, this error doesn't occur in WP 6.7, so I'll add this issue to the 6.8 project board.

@t-hamano
Copy link
Contributor

Slightly related to this issue, there is also the issue of not being able to access pattern categories or template parts in the mobile view.

#67505 was filed to solve this, but unfortunately, it seems to have been closed.

@t-hamano t-hamano added the Mobile Web Viewport sizes for mobile and tablet devices label Jan 29, 2025
@Mamaduka Mamaduka moved this to 📥 Todo in WordPress 6.8 Editor Tasks Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile Web Viewport sizes for mobile and tablet devices [Package] Edit Site /packages/edit-site [Type] Bug An existing feature does not function as intended
Projects
Development

Successfully merging a pull request may close this issue.

2 participants