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

[Merl 1149] Add TextControl field #1560

Merged
merged 8 commits into from
Sep 7, 2023
Merged

[Merl 1149] Add TextControl field #1560

merged 8 commits into from
Sep 7, 2023

Conversation

theodesp
Copy link
Member

@theodesp theodesp commented Sep 5, 2023

Tasks

  • I have signed a Contributor License Agreement (CLA) with WP Engine.
  • If a code change, I have written testing instructions that the whole team & outside contributors can understand.
  • I have written and included a comprehensive changeset to properly document the changes I've made.

Description

  • registerFaustBlock Edit function now handles text control fields.

Related Issue(s):

#1522

Testing

Follow testing instruction from this PR:

#1559

  • Make sure to add a field with type: text.
  • Create a new block. You should be able to see the text fields for that attribute. You should be able to update the field and the field should persist when saving the post/page.

Screenshots

Screenshot 2023-09-05 at 14 39 32 Screenshot 2023-09-05 at 14 40 07

Documentation Changes

Dependant PRs

@changeset-bot
Copy link

changeset-bot bot commented Sep 5, 2023

🦋 Changeset detected

Latest commit: e03a555

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@faustwp/block-editor-utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2023

📦 Next.js Bundle Analysis for @faustwp/getting-started-example

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 242.65 KB (🟡 +25 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

@theodesp theodesp marked this pull request as ready for review September 5, 2023 13:40
@theodesp theodesp requested a review from a team as a code owner September 5, 2023 13:40
@TeresaGobble
Copy link
Contributor

Thank you for your work on this, @theodesp! I had some questions on expected behavior to clarify with you on this item, as well as a related question about the associated RFC and some assumptions I may be making.

Below, I've tested out the block in my example, following the instructions above. I'm noting the text control field, which looks as expected based on the WordPress TextControl component. 👍

My concern now is whether the TextControl field is behaving as expected when clicking away from the block in the editor, and when examining the block contents on the front-end post.

Screen.Recording.2023-09-05.at.3.57.48.PM.mov

When clicking away from the block in the editor, I seem to just see the attribute message default from the block.json file in the testing plugin, "Hello World" instead of my text input, "A little message." "Hello World" also appears as the content in my block on the front-end, instead of the text in the text control field ("A little message"). However, the input does appear to persist after refreshing the page in editing mode in the block.

Is this block working as expected?

If not, I have a follow-up question on testing. In my HelloWorld.js made as part of testing instructions, I have added this editorField, message2:

HelloWorld.config = {
	name: "HelloWorld",
        editorFields: {
		message: {
			type: "string",
			default: "",
			label: "My Message",
			location: "editor",
			control: "textarea",
		},
		bg_color: {
			location: "editor",
			control: "color",
		},
        message2: {
			type: "string", 
			default: "text default",
			location: "editor",
			control: "text",
        },
	},
};

I have it here as type: "string" because in the RFC here, this seems to resolve to the correct type for the TextControl field. But the testing instructions above say to add a type: text. Am I off base with my understanding of how the registerFaustBlock helper works?

Here is my testing plugin's block.json as well for reference:

	"$schema": "https://schemas.wp.org/trunk/block.json",
	"apiVersion": 2,
	"name": "create-block/hello-world-block",
	"version": "0.1.0",
	"title": "Hello World Block",
	"category": "widgets",
	"icon": "smiley",
	"description": "Example block scaffolded with Create Block tool.",
	"supports": {
		"html": false
	},
	"attributes": {
		"message": {
			"type": "string",
			"default": "Hello World"
		},
		"bg_color": { "type": "string", "default": "#000000" },
		"message2": {
			"type": "string",
			"default": ""
		}
	},
	"textdomain": "hello-world-block",
	"editorScript": "file:./index.js",
	"editorStyle": "file:./index.css",
	"style": "file:./style-index.css"
}

Copy link
Contributor

@TeresaGobble TeresaGobble left a comment

Choose a reason for hiding this comment

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

Thank you for your thorough walkthrough of expected behavior and my questions on the RFC, @theodesp! This LGTM! 😊 ✨

@theodesp theodesp merged commit db848c4 into canary Sep 7, 2023
13 checks passed
@theodesp theodesp deleted the MERL-1149 branch September 7, 2023 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants