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

Experiment: use the Interactivity API to do client-side form submissions #49305

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 52 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
"@wordpress/warning": "file:packages/warning",
"@wordpress/widgets": "file:packages/widgets",
"@wordpress/wordcount": "file:packages/wordcount",
"deepsignal": "1.3.0",
"preact": "10.13.1",
"wicg-inert": "3.1.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"sideEffects": [
"build-style/**",
"src/**/*.scss",
"{src,build,build-module}/*/init.js"
"{src,build,build-module}/**/init.js"
luisherranz marked this conversation as resolved.
Show resolved Hide resolved
],
"dependencies": {
"@babel/runtime": "^7.16.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/block-library/src/post-comments-form/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"usesContext": [ "postId", "postType" ],
"supports": {
"interactivity": true,
"anchor": true,
"html": false,
"color": {
Expand Down Expand Up @@ -44,5 +45,6 @@
"wp-block-post-comments-form",
"wp-block-buttons",
"wp-block-button"
]
],
"viewScript": [ "file:./view.min.js" ]
}
9 changes: 7 additions & 2 deletions packages/block-library/src/post-comments-form/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ function render_block_core_post_comments_form( $attributes, $content, $block ) {
$form = str_replace( 'class="comment-respond"', $wrapper_attributes, $form );

// Enqueue the comment-reply script.
wp_enqueue_script( 'comment-reply' );
// wp_enqueue_script( 'comment-reply' );

return $form;
$tags = new WP_HTML_Tag_Processor( $form );

$tags->next_tag( array( 'tag_name' => 'FORM', 'id' => 'commentform' ) );
$tags->set_attribute( 'data-wp-on.submit', 'actions.core.commentsFormSubmission' );

return $tags->get_updated_html();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const csnMetaTagItemprop = 'wp-client-side-navigation';
export const componentPrefix = 'wp-';
export const directivePrefix = 'data-wp-';
Loading