-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
UI/UX for connecting block attributes to custom fields #53891
Comments
This is a POC i made for myself some days ago of I would like this feature to be implemented... POC - The UXKapture.2023-08-23.at.22.04.17.mp4 |
CC @WordPress/gutenberg-design |
Nice @tresorama! Are you using #42015 in your POC? It seems more related to the discussion around inline tokens (#39831) than the current issue. How would you imagine your proposal working beyond plain text content, e.g., with Images/media? |
Thanks. I'm not using #42015 because i didn't know it exists :) I used a mini parser with the same idea to replace tokens with real value coming from the redux store. I haven't moved on over "textual" data because of time, but i think that for example "core/image" block can have an additional source in the initial modal (and also in "replace" popover) Or maybe move every source inside the same dropdown (link in Bricks, shown below) ?? Bricks UX with Dynamic DataMy vision is heavily influenced by Bricks Builder, so i'd like to see in Core Gutenberg a UX flow similar to Bricks.
Here is a recording of using Bricks with Dynamic Data Kapture.2023-08-25.at.09.22.43.mp4Considerations:Bricks show every possible Dynamic Data source in every dynamic data dropdown, even if :
For the first, Here is an example of a type mismatch in Bricks Kapture.2023-08-25.at.09.42.00.mp4For the second, const useDynamicDataSources = (props: BlockEditProps<any>) => {
const { attributes, context } = props;
// extract dynamic data fields "names" and return as list
// fetch data
const post = useEntityRecord<Post>('postType', context.postType, context.postId);
const acfFields = post.record.acf || {};
// build list
return [
{ section_name: 'Post', fields: ['post_title'].map(_ => "{" + _ + "}") },
{ section_name: 'ACF', fields: Object.keys(acfFields).map(_ => "{acf:" + _ + "}") },
] satisfies { section_name: string, fields: Array<string>; }[];
}; In case here is the full code of my POC |
Builder that solved the same problem that can be used as inspiration in this design phase are:
@michalczaplinski maybe you could add these in the main issue to have them togheter |
The user should edit the custom fields (or other data sources) either inside the block content (or related popup) or in a block inspector panel. Not in an external editor! Instead of trying to connect attributes to data sources from within the block’s UI we should offer an ‘Attributes’ panel. In this panel we make connections, add placeholders, labels, add input instructions, set defaults, set the attribute to be read only or read-write and allow creation of new data source fields. Here we could also define options the user may select from and set any other configuration needs. This panel should by default only be available to administrators, I think. When switching an attributes data source the current value should preferably be moved to the new data source. If the new data source already has a value then the user should choose which value to keep. So values are mainly edited in the editor or a block inspector panel while attribute connections are configured in the Attributes block inspector panel. |
@michalczaplinski and @SantosGuillamot, is this issue still actionable? There are other issues opened that seem to cover similar topics. |
@gziolo There isn't anything directly actionable, but we can keep this issue open for now and once work on the UI/UX picks up we can link from here and/or close this issue. Quick summary:Connecting block attributes to custom fields is one of the main aspects of the Block Bindings project. It was shipped in WP 6.5 (#53300). Current work is tracked in: |
Implemented with: More in What’s new in Gutenberg 19.0? (14 August): gb-19-block-bindings.mp4 |
Work has started to implement the vision outlined in Custom fields 🔗 Blocks. and is being tracked in #53300.
However, we need a more holistic vision of the UI/UX for the connections between the blocks' attributes and the custom fields. This issue aims to explore the possible UI/UX for those connections.
Current State
2 PRs have been merged that allow connecting the
Paragraph
block'scontent
attribute to custom fields:Another (draft) PR is exploring connecting the
Image
block'surl
andtitle
attributes to custom fields:This is what connecting the attributes looks like at the moment for both Image and Paragraph blocks (includes the changes from the unmerged PR):
original.mov
This UX is not optimal and needs refinement.
Open Questions
Those are roughly in the order of importance:
How to edit the custom fields?
Inside of the block content, like in Add custom attributes sources block support #51375
Using an external editor? (like using ACF or the built-in custom fields GB panel). This is what the built-in custom fields panel looks like:
Using a different approach for each block.
Maybe a single UI does not make sense for all blocks, and we need to design it in a way that makes sense for each block individually.
content
attribute to custom fields, it might make sense to edit the value in the block content.url
attribute you can select the custom field after inserting the block:title
or other attributes, there might be inspector controls (like it works currently)UI for connecting more than one attribute of a block to custom sources.
Currently, only the Image block has more than 1 connection, but this will change in the future. Having an input field per "connectable" attribute (as in the current MVP) is not tenable.
How to show the list of available fields? (ideally with autocomplete)
There is prior art for this:
UI for adding a new custom field inline
It should be possible to create new custom fields on the fly using the same UI where the attributes get connected to custom fields.
Interaction between existing block content and the connection value in the editor
If a block has existing content and then gets connected to a custom field, what should happen to this existing content? Ideally, we'd like to keep it in the background somehow, and if a user removes the connection, show that content again. Currently, we remove the existing content in the Paragraph block and show a placeholder. What should this process look like for other blocks and attributes?
Selecting a specific value from a custom field that is an
array
orobject
Custom fields can be more than strings and numbers. We need some way to select/filter those.
If the connection has a default value, how should this be shown to the user?
We want the connections to define a "default" value that should be used in case the custom field we're connecting to does not exist. It should be indicated to the user that the "default" value is being used instead of the value from the connection.
UI for selecting a “connection source” (meta fields or something else)
This is not a priority because, for now, the only "connection source" is "custom fields", but there will be others in the future like "parent block" or another external source.
Validation
This one is probably optional for now, but ACF and similar plugins allow users to define validation rules for each field.
The text was updated successfully, but these errors were encountered: