-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: new Curated List block, block pattern, and map functionality #3
Conversation
Sets up custom post types and Listing block prototype.
Instead of just registering a single Listing block and selecting the type in the parent post, this registers a separate block for each listing type (all of which use the same code).
Addresses pull request feedback and refactors post types config into a more DRY treatment.
This removes the Curated List CPT in favor of a wrapper block that can be inserted into any other post or page. This block can contain Listing blocks to create curated lists anywhere, and can be converted to a Reusable Block if it needs to be reusable.
Lays out a method of passing attributes data from the Curated List block to its child Listing inner blocks, without relying on contexts. We basically duplicate parent block attributes on each child block and sync the values of those attributes.
This establishes a pattern for providing block patterns for particular listings CPTs. This might let us provide structured content without having to register metadata fields for listing content.
Adds support for location-based data using the jetpack/maps block. If a listing CPT of any type contains a jetpack/map block with location data, the location data is used to show the listing on a map for any Curated List blocks containing the listing post.
Sets up a sync from certain content blocks to post meta fields. This will help us more easily implement search/filter functionality for listing posts on a large scale.
We want to avoid letting editors nest Curated Lists inside list items which could be nested inside Curated Lists which could be inside list items which could be... etc.
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.
I did a pass at some functional testing, and a few things came up:
-
The block pattern only appears if the Gutenberg plugin is enabled. Without it, the Patterns panel doesn't have the category drop down, and the custom category isn't shown.
-
Curiously, the Curated List block only appears if Gutenberg is disabled. I was not able to determine the cause.
-
In the Curated List block, after clicking Replace Listing, the item being replaced appears in the autocomplete results. The testing instructions indicate this should not be happening.
-
When starting fresh on a new site, all of the single pages returned Not Founds. Flushing permalinks resolved this, but I expected flushing to be necessary only if a previous version of the plugin had been in use?
-
I was able to add the same Listing multiple times in the Curated List block.
Block patterns and block pattern categories can only be registered on init or admin_init hooks in WP 5.5.
Nice catch—this is fixed in 48d027c. Apparently in older versions of Gutenberg, the
I'm not able to reproduce this. I see the Curated List block as an available block in posts and pages both with and without the Gutenberg plugin (my WP version: 5.5.1). I also tested both with and without Newspack and Newspack Blocks plugins activated. The plugin relies on some functions that were introduced in WP 5.5, so maybe verify that you're running this locally?
I believe I stealth-fixed this in 7349944 (in #5). Let's revisit and retest this in that PR, if possible? The issue is that I introduced a middleman wrapper block to contain the list items inside the Curated List block, so I need to explicitly look for the InnerBlocks for that middleman block instead of the InnerBlocks of the top-level Curated List block.
Should be fixed with 39d2912. Closes #2.
This is related to item (3) above. Should be fixed with 7349944 in #5. Let's revisit and retest there. |
Had trouble with this flow:
|
I was able to add the same listing twice to a single curated list block. Demo: |
This control doesn't seem to be having any effect in the editor. The block respects the state of the setting when the editor page is first loaded, but toggling doesn't change it. The front-end display appears to correctly reflect the editor state, however. Demo: https://cloudup.com/clovAWq-E2g UPDATE: Similar issue with the Featured Image Caption toggle. UPDATE: Also, some issue related to changes to the caption toggle. At the end of this demo the toggle is switched on the post published, but the captions don't appear in front end. |
I am seeing the Business Listing pattern in all Listing post types, e.g. Generic Listing. However, I don't see it in normal Posts. |
I actually like the approach! It seems to work well and is a clever way to bridge the gap between block-based authoring and structured data, at the same time maintaining a single source of truth. Do you have any specific nagging concerns? |
I think we'll be able to achieve this, but don't worry about it in this PR. I'd open an issue in this repo so we can track, then we can open a Jetpack PR enabling that level of control. |
I might be misunderstanding the question, but are you trying to add a control to that? If so, the component is |
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.
I did a bunch more functional testing and left comments about any situation where the experience didn't match the testing instructions. Since the PR is so big I didn't try to tie the comments to specific code and simply left them as comments on the PR - I hope this isn't confusing. Note that all testing occurred with Gutenberg 9.2.1 installed.
@jeffersonrabb Apologies if this is confusing. Several of the issues you brought up are or will be addressed in other PRs:
Given the above, and that this plugin is not yet released, I think the best course of action is to merge this and re-test the above in #5 and #6, do you agree? To answer your questions:
I'm glad this sounds like the right approach to you! My main concern is the dependency on Jetpack. Currently if the plugin loads on a site without Jetpack, we simply don't show Jetpack-dependent features such as the map, business hours, and contact info blocks in the Business pattern. Although maybe this is not really a concern since all Newspack customers will have Jetpack. Then there's always the concern that the Jetpack team will change this block in a way that breaks our functionality, since this plugin expects Jetpack Map attribute data to be formatted in a particular way.
What I actually want to do is hide or disable the BlockControls for the map inside a Curated List block. Currently, when you toggle map functionality on, the block automatically creates a map with the right locations based on the items in the list. But you're able to move the map around, remove it, or even add additional map blocks to the list, which could seem like a mistake. I think this is a relatively minor UX concern, though. |
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.
🎉 This PR is included in version 1.0.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
# 1.0.0-alpha.1 (2021-07-19) ### Bug Fixes * avoid meta sync update error ([#95](#95)) ([cab16aa](cab16aa)) * do not register post-specific sidebars in widgets page ([#93](#93)) ([7716775](7716775)) * editor errors with reusable blocks ([#89](#89)) ([fdc46d3](fdc46d3)) * errors and bugs related to WP 5.8 ([#83](#83)) ([90da6c5](90da6c5)) * force alpha rebuild ([acc2075](acc2075)) * minor bug fixes ([#21](#21)) ([5f90bc7](5f90bc7)) * missing condition for block appender in list container ([#74](#74)) ([2c49896](2c49896)) * syncing attributes from curated list block to inner blocks ([#64](#64)) ([cdbc0bb](cdbc0bb)) * use synced attributes for ListContainer directly ([#73](#73)) ([f8641a7](f8641a7)) ### Features * add block patterns ([#23](#23)) ([a273a40](a273a40)) * bump max number of items per list from 20 to 50 ([#97](#97)) ([009deab](009deab)) * initial post type and block setup ([#1](#1)) ([47dc0c1](47dc0c1)) * listing taxonomies and query mode ([#6](#6)) ([528e1e5](528e1e5)) * more block patterns (real estate, classified ads) ([#84](#84)) ([a51f5af](a51f5af)) * new Curated List block, block pattern, and map functionality ([#3](#3)) ([9be6e7e](9be6e7e)) * remove borders and padding in editor to match front-end styles ([#14](#14)) ([6c47a17](6c47a17)) * v2 release (#85) ([748810d](748810d)), closes [#85](#85) [#40](#40) [#39](#39) [#32](#32) [#41](#41) [#49](#49) [#43](#43) [#56](#56) [#51](#51) [#57](#57) [#61](#61) [#67](#67) [#60](#60) [#70](#70) [#65](#65) [#71](#71) [#66](#66) [#58](#58) [#77](#77) [#81](#81) ### BREAKING CHANGES * This feature will deprecate existing custom taxonomies, so any existing terms for those taxonomies will be lost. To fix, we can convert terms from the deprecated taxonomies to standard post categories/tags via a migration script.
All Submissions:
Changes proposed in this Pull Request:
Establishes a Curated List block in favor of the now-deprecated Curated List CPT. This means that Curated Lists are simply instances of the new block, which can be turned into reusable blocks like any core block.
Also implements the first block pattern (Business Listing) to establish the idea of using block patterns to help editors create listings of different types using a small number of CPTs.
Also implements experimental map functionality using the Jetpack Map block.
How to test the changes in this Pull Request:
Before testing
Creating a Curated List
Click the [+] appender button inside the Curated List block and observe that the only blocks available to insert are the listing blocks (Event, Generic, Marketplace, or Place listings).
Add a listing of any type (currently, there is no functional difference between any of the listing types, although this will change in the future). Observe an autocomplete search field in the listing block.
If you haven't created any listings of the type you added, create and publish some with any amount of test content, or click the "Create new [listing type]" button from within the Curated List block editor.
After you have several published listings, search for the listing by title in the autocomplete search bar. Confirm that selecting the listing changes the render of the listing item block to show a preview of the selected post's content.
Confirm that clicking "Replace listing" re-shows the search field and lets you type a new listing title into the autocomplete field.
Confirm that a.) the listing currently shown by this block isn't shown in autocomplete results, b.) selecting a different post replaces the preview with the new post, and c.) clicking "Cancel" here instead of selecting a new post goes back to the post preview display.
Add more listings of any type to your Curated List block. Observe that within the Curated List block, each specific post can only be added once (e.g. a listing post won't be shown in autocomplete results if it already exists in the list). Also confirm that listings CAN be added to different Curated List block instances within the same post.
Publish the post. View the front-end. Observe that a.) The list displays the selected items in the same order as shown in the editor, and b.) each item links to a singular page for that listing post.
In the editor, change the order of listing items within the Curated List. Update the post, refresh the front-end and observe that the list item order still matches between editor and front-end.
Test the following Curated List block attributes (which are currently the only ones that are functional):
Newspack Listing block patterns
There is one block pattern registered as part of this PR. This is just to establish the foundation for configuring and registering others. We will probably want to involve design in drafting a list of patterns to create and how they should look.
To test the Business Listing pattern:
Map/Geolocation functionality
This PR leverages the Jetpack Map block to allow editors to add location data to listings, and to show all locations on a single map for Curated List wrapper blocks. To test:
Questions
This also ties in with the question above about block content vs. meta fields. All geolocation data is stored in each listing post as block content rather than structured data. Does this paint us into a corner by not being able to easily search/filter by this content?UPDATE: We're now doing both! :porquenolosdos: On the back-end, we're hooking into thesave_post
action on listing CPTs and looking for the existence of certain blocks in the post content. If those blocks exist in content, we parse the blocks and save certain attributes into post meta. Details here: 49d93c8experimentalUIParts
API that let you hide this toolbar and other UI elements, but it seems to have been removed in recent Gutenberg versions. Just wanted to see if there are other patterns that anyone knows of that I haven't discovered yet.Other information: