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

Enhance 404 message styling #69234

Merged
merged 6 commits into from
Feb 20, 2025

Conversation

Infinite-Null
Copy link
Contributor

@Infinite-Null Infinite-Null commented Feb 18, 2025

Closes: #69174

What?

This PR improves the error message displayed on 404 (Not Found) pages in the Site Editor.

Testing Instructions

  1. Navigate to the Site Editor
  2. Try to access a non-existent template by entering an invalid URL:
/wp-admin/site-editor.php?p=%2Ftemplate-fdgfdgdfg
  1. Verify the error appears as a proper error Notice component.

Screenshots

Desktop

Before After
image image

Mobile

Before After
image image

@@ -264,6 +264,7 @@ html.canvas-mode-edit-transition::view-transition-group(toggle) {

.edit-site-layout__area__404 {
margin: $canvas-padding;
color: $gray-800;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After PR #69226 gets merged. This line won't be necessary.

@Infinite-Null Infinite-Null marked this pull request as ready for review February 19, 2025 06:20
Copy link

github-actions bot commented Feb 19, 2025

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: Infinite-Null <ankitkumarshah@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>
Co-authored-by: carolinan <poena@git.wordpress.org>

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

@Infinite-Null
Copy link
Contributor Author

Infinite-Null commented Feb 19, 2025

Hi @t-hamano
I have included the Notice component and improved the 404 message in this PR. I would truly appreciate it if you could take a moment to review the updated 404 message and the Notice component.

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Now that #69226 has been merged, the color overrides are no longer necessary. Can you rebase this PR?

Here are three things I noticed:


The browser console gives me an error: I think we need to replace the description wrapper with a div tag instead of a p tag:

react-dom.js?ver=18:73 Warning: validateDOMNesting(...): <div> cannot appear as a descendant of <p>.

This may be a matter of preference, but you can also do something simpler like this:

function NotFonundError() {
	return (
		<Notice status="error" isDismissible={ false }>
			{ __(
				'The requested page could not be found. Please check the URL.'
			) }
		</Notice>
	);
}

export const notFoundRoute = {
	areas: {
		mobile: (
			<SidebarNavigationScreenMain
				customDescription={ <NotFonundError /> }
			/>
		),
		content: (
			<Spacer padding={ 2 }>
				<NotFonundError />
			</Spacer>
		),
	},
};

I'm a bit undecided whether to use the error or warning status.

@t-hamano t-hamano requested review from carolinan and a team February 19, 2025 14:05
@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. Needs Design Feedback Needs general design feedback. [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Feb 19, 2025
@joedolson
Copy link
Contributor

I'm a bit undecided whether to use the error or warning status.

I'm somewhat inclined towards error; but also fairly undecided.

@Infinite-Null
Copy link
Contributor Author

Infinite-Null commented Feb 20, 2025

Hi @t-hamano,
Thank you for the feedback.
I have updated the implementation and made NotFoundError a reusable component and used it in both content and mobile areas. Also removed:

.edit-site-layout__area__404 {
	margin: $canvas-padding;
}

as it is no longer required.

Please review it at your convenience.

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Thanks for the update!

Can you fix this browser console error?

The browser console gives me an error: I think we need to replace the description wrapper with a div tag instead of a p tag:

react-dom.js?ver=18:73 Warning: validateDOMNesting(...): <div> cannot appear as a descendant of <p>.

image

@Infinite-Null
Copy link
Contributor Author

Hi @t-hamano,
I have fixed the console error as you suggested Please review it at your convenience.
Thank You!

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

I think the error status is fine for now.

By the way, we plan to display some text when you access a screen where the classic theme is not allowed to be used (#69005).

Let's take into consideration the status of the PR and if we think a warning status would be more appropriate, we can address it in a follow-up.

@t-hamano t-hamano merged commit 0f7193c into WordPress:trunk Feb 20, 2025
61 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.4 milestone Feb 20, 2025
@Infinite-Null
Copy link
Contributor Author

Infinite-Null commented Feb 20, 2025

Hi @t-hamano, I was wondering if adding an E2E test for the 404 page would be beneficial. I’m unsure if it. Do you think it’s worth adding? If so, I’d love to work on it.

@t-hamano
Copy link
Contributor

I was wondering if adding an E2E test for the 404 page would be beneficial.

Yes, I think that's a good idea.

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") Needs Design Feedback Needs general design feedback. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add centered and larger text styling for message display of 404 route
3 participants