-
Notifications
You must be signed in to change notification settings - Fork 812
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
Fix form validation with js disabled #41947
base: trunk
Are you sure you want to change the base?
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
@@ -346,7 +346,7 @@ public static function parse( $attributes, $content ) { | |||
} else { | |||
// Submit form to the post permalink | |||
$url = get_permalink(); | |||
if ( $page ) { | |||
if ( $multipage && $page ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix is to only add the ?page
query param to the form submission url if the post has more than one page. The $multipage
global stores whether it's a multi page post with a value of 0
or 1
so we can use that to check.
Perhaps in classic themes it was possible for users to navigate to a URL like that and not end up on a 404 page, but it doesn't seem to be the case in block themes.
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
Fixes part of #41942
Proposed changes:
Fixes a bug where, if the user has JavaScript disabled in their browser, and tries submitting an invalid form, the user ends up on a 404 page instead of staying on the same page with form validation errors shown.
This is only a partial fix, there's still a bug mentioned in the comments on the issue, where I also mention how it seems to have been introduced - #41942 (comment).
The remaining bug is that the user needs to submit the invalid form twice for the validation issues to show. It's not great, the first time submitting the form will be reset. The fix is probably going to be quite considerable, or involve reverting the PR mentioned in the comment, but that would bring back another (much worse IMO) bug.
I expect this is very low priority though, most users won't have JS disabled, so I don't plan to work on it further than this.
Other information:
Does this pull request change what data or activity we track or use?
No
Testing instructions:
In trunk: The user ends up on a 404 page
In this PR: The page reloads