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

Issue#84/faq block #86

Merged
merged 30 commits into from
May 9, 2023
Merged

Issue#84/faq block #86

merged 30 commits into from
May 9, 2023

Conversation

jessica-townsend
Copy link
Contributor

@jessica-townsend jessica-townsend commented May 5, 2023

Relevant Issues

What Was Accomplished

  • Added new FAQ block with a heading for the question and lists/paragraphs for the answer.
  • Injected an FAQ Page schema to the footer without using parse_blocks
  • Added an Inline custom style for the FAQ block, which is also reflected in the editor
  • Added ability to transform old FAQ blocks into new FAQ blocks

How It Was Tested

  • Locally on parent theme
  • Staging on child theme

How To Test

  • Custom FAQ block can be added through the editor (icon for our block is a question mark)
  • Only heading and list blocks are available to add in the FAQ block
  • Selecting the inline style for the FAQ block displays the question heading and the next paragraph in the block side by side in the editor. Lists immediately following the question heading are not displayed inline.
  • An old FAQ block can be transformed into our new FAQ block through the editor
  • Google's Rich Results Test detects a valid FAQ Page item
  • Answer text in the schema is stripped of any unsupported tags and all attributes besides href for anchor tags

Open Items

  • Need to update the parent theme to properly display the inline FAQ block style
  • Need to update child themes to update question heading default font size

@douglas-johnson
Copy link
Member

I foresee an issue where people accidentally delete the heading, don't know how to get it back with the correct class name, and it silently doesn't output the schema.

In the latest version of Gutenberg, group gets its own allowedBlocks attribute. So when that hits WP core, we could use templateLock on the FAQ. The heading and group would be locked in place and the group could only contain the blocks we allow.

https://github.com/WordPress/gutenberg/releases/tag/v15.7.0
WordPress/gutenberg#49128

So I'm suggesting:

  • bring back the group, the way you originally had it
  • update the description ( and possibly placeholders ) to advise that people only use paragraphs and lists in the answer
  • plan to implement allowedBlocks when it hits WP core

@douglas-johnson
Copy link
Member

After my previous comment I remembered why we wanted to get rid of the group. I think we can have both template locking and the styling we want, it just might take multiple blocks. Let's discuss today.

@jessica-townsend
Copy link
Contributor Author

@douglas-johnson could we just lock the heading block individually and leave everything else unlocked?
https://developer.wordpress.org/block-editor/reference-guides/block-api/block-templates/#individual-block-locking

@douglas-johnson
Copy link
Member

@jessica-townsend yes, christ! if that works that's amazing. I saw someone doing that on github but I couldn't find it in the docs.

@jessica-townsend
Copy link
Contributor Author

Cool, I have that up on staging if you'd like to review it @douglas-johnson

@douglas-johnson
Copy link
Member

The locking works great. I'm glad it was so simple, thank you for figuring that out.

I would you like to discuss just one more thing. I think its unintuituve to get out of the FAQ block using the keyboard. I had to hit my up arrow so the FAQ block was selected, then hit enter.

If I just hit enter, it adds new paragraphs in the FAQ.

Screenshot 2023-05-09 at 9 32 32 AM

Take a look at how the group block works. If you hit enter in an empty paragraph, it moves you out of the group block.

I thought that was handled by an onSplit function but it turns out that might be from this __experimentalOnEnter

https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/group/block.json#L24

Can you try declaring support for it in the FAQ block.json and see if it works?

@jessica-townsend
Copy link
Contributor Author

@douglas-johnson this worked for me. I pushed to staging too

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.

FAQ Block
2 participants