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

FSE: Add a site description block. #33720

Merged
merged 15 commits into from
Jun 18, 2019
Merged

FSE: Add a site description block. #33720

merged 15 commits into from
Jun 18, 2019

Conversation

kwight
Copy link
Contributor

@kwight kwight commented Jun 6, 2019

Changes proposed in this Pull Request

Let's add a basic site description block, for use with Full Site Editing.

Testing instructions

  • Load your FSE testing environment with this branch active.
  • Add a "Site Description" block anywhere you like (it's not yet scoped to anything in particular).
  • Verify that the Edit preview represents the same data and styling as on the site's front-end.

Fixes #33107 .

@matticbot
Copy link
Contributor

@kwight kwight requested a review from a team June 6, 2019 23:07
@kwight kwight self-assigned this Jun 6, 2019
@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@kwight kwight force-pushed the add/fse-site-description branch from 918a344 to 07d134b Compare June 11, 2019 19:56
@kwight kwight changed the title FSE: Add a site description block. [WIP] FSE: Add a site description block. Jun 12, 2019
@kwight kwight added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Jun 12, 2019
<PlainText
className="wp-block-a8c-site-description"
value={ this.state.value }
onChange={ value => this.setState( { value } ) }
Copy link
Member

Choose a reason for hiding this comment

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

We should also update an attribute of this block when we change the site description within the block. Otherwise, the editor won't be aware that the page content has changed and the "Update" button will remain disabled:

Jun-13-2019 14-18-15

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, interesting; my Update button is always available (although that makes no sense either 🙃 ). Will dig further. But we don't want to be saving attributes for this block (we shouldn't ever see <!-- wp:a8c/site-description {"description":"tagline"} /--> in markup for instance) 🤔

Copy link
Member

Choose a reason for hiding this comment

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

componentDidUpdate( prevProps ) {
if (
prevProps.isSaving === false &&
this.props.isSaving === true &&
Copy link
Member

Choose a reason for hiding this comment

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

This is also updating the site description during autosaves (i.e. when clicking on the Preview button), but I think we should only update it when the user explicitly has clicked on the Publish/Update button.

@kwight kwight requested a review from a team as a code owner June 13, 2019 18:58
@kwight kwight force-pushed the add/fse-site-description branch from 4e506cb to 6f6798b Compare June 13, 2019 20:06
@mmtr
Copy link
Member

mmtr commented Jun 14, 2019

I noted you removed the previous code that was allowing to update the site description from the block. Are you planning to add that back on this PR?


componentDidMount() {
const { setAttributes } = this.props;
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is equivalent to apiFetch.then( successHandler, rejectHandler ) or apiFetch.then( successHandler ).catch( anyThrownErrorsFromErrorOrSuccessHandler );

@kwight kwight force-pushed the add/fse-site-description branch from 5cf206b to 6c7a1de Compare June 17, 2019 20:11
@kwight kwight requested a review from a team as a code owner June 17, 2019 20:11
@kwight
Copy link
Contributor Author

kwight commented Jun 17, 2019

I noted you removed the previous code that was allowing to update the site description from the block. Are you planning to add that back on this PR?

I did! I stripped it out because I was getting confused while sorting the attributes. With attributes working properly, I can add it back in, yes 👍

@mmtr
Copy link
Member

mmtr commented Jun 18, 2019

@kwight I committed some changes reverting the usage of attributes and moving back to a local state approach. We have #34004 in progress to determine a better way to make the Publish button clickable when there are changes in the site blocks. That means that I also added back the logic that was saving the description.

In the last commit (c2efb58) I also modified the code to align it more with the work done in #33761. Feel free to review those changes and land this PR if you're happy with them or change anything you want :)

@@ -312,7 +312,7 @@ public function enqueue_script_and_style() {
wp_enqueue_style(
'a8c-full-site-editing-style',
plugins_url( 'dist/' . $style_file, __FILE__ ),
array(),
'wp-edit-post',
Copy link
Member

Choose a reason for hiding this comment

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

This is to ensure that our styles are loaded after the Gutenberg styles for the editor, making easier to override a specific style.

@kwight
Copy link
Contributor Author

kwight commented Jun 18, 2019

@mmtr Ooooh, fantastic, thank you – I ❤️ it all (and you managed to get the error notices in there too!). I've added some followup questions/tasks in #34093, but I'll go ahead and merge this as-is. 🎉

@kwight kwight merged commit 88abad2 into master Jun 18, 2019
@kwight kwight deleted the add/fse-site-description branch June 18, 2019 17:04
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jun 18, 2019
* External dependencies
*/
import apiFetch from '@wordpress/api-fetch';
import { PlainText } from '@wordpress/block-editor';
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably should use the older editor package until support is dropped. This will allow for Gutenberg support across more versions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, will do, good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kwight kwight restored the add/fse-site-description branch June 18, 2019 17:17
@kwight kwight deleted the add/fse-site-description branch June 18, 2019 17:17
import './style.scss';

registerBlockType( 'a8c/site-description', {
title: __( 'Site Description2' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

@kwight Typo?

Copy link
Member

@mmtr mmtr Jun 19, 2019

Choose a reason for hiding this comment

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

That was me trying to verify I was getting the latest build on my local environment 😅. Will prep a PR reverting this in a bit

Copy link
Member

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Post/Page Editor The editor for editing posts and pages. [Goal] Full Site Editing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Full Site Editing: Site Description (Tagline) block [8]
5 participants