-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Draft: Use DataViews for post-meta and custom sources block bindings. #67012
base: trunk
Are you sure you want to change the base?
Conversation
Interesting. Using a modal for adding inputs might work, data views if there are many pages would certainly also be a good component to use. However there seems to be an ItemGroup thrown into the mix, is that right? If we're going to use DataViews it should be the vanilla component, recognizable. I think there's a question, however, of whether DataViews is meant to be used in a modal, in a context such as this. CC: @jameskoster in case you have thoughts. |
Tagging also @oandregal and @youknowriad for general awareness in case they have any thoughts to share. |
For me DataViews are meant to be used anywhere we want to render a list of structured data. So having it in a modal or not is not really a problem for me. That said, for now, dataviews is a bit optimized for switching layouts, configuration... So I think if we want to absorb more use-cases, we should look into pushing this issue to resolution #63646 |
className="block-editor-bindings__modal" | ||
> | ||
<DataViews | ||
getItemId={ ( item ) => item.label } |
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 see the dataSet
is an array of objects that have the following keys: id
, label
, value
. Is the id
unique among the items? It seems so. If my understanding is correct, getItemId
could be removed here.
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.
Done
const fields = [ | ||
{ | ||
id: 'label', | ||
label: 'Label', |
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'd like to make the type
required soon. There're some fallbacks for things such as sorting to work in most common cases (text, number, date), but it'd be great to be more explicit here by providing type: text
.
Agree that conceptually this is fine, but looking at the video in the OP my reaction is that |
The demo shows a small number of items, but in some cases, there may be 1000s of them (context). Perhaps we'd let consumers choose to use a simple picker or a more advanced data view? |
I see a lot of similarities between these two ideas. I agree that DataViews fit perfectly where you have a large set of data, you need to search for items, filter them, select multiple of them. This is precisely why the mockup attached for Remote Data Blocks looks so good. I would like to point out that the block editor's "Attributes" panel's role is currently limited to associate one of the options exposed by the block bindings source with any available block attribute. In effect, it isn't concerned yet with editing the value. I would like to understand better how that flow looks like in Remove Data Blocks as to me, it seems oriented towards selecting then a source (Remote Data), then an option (Conference Events or ClothingStore.co), then the DataView is used to select the value (Product: Powder Blue Jacket or Event: 11 items). In contrast, what @cbravobernal has explored so far was selecting an attribute ( |
I'm torn. My first impression on opening the modal was, "This is a lot of information." I imagine many users could have a similar reaction. At the same time, the modal isn't too bad once you get used to it, and the benefits of the modal and DataViews for advanced use cases is clear. Going either way — with or without the modal — may lead to a less-than-optimal user experience for a large number of WordPress users.
Can we get feedback from users on this? I left a message on WordPress Slack and tagged a couple of folks who I know have some familiarity with Block Bindings ( Here I'll directly ping @carstingaxion @mauteri @afercia @kraftner — any thoughts appreciated! Please feel free to tag anyone else who may have thoughts. |
Pinging @WordPress/outreach for feedback. |
I personally lean towards reusing DataViews and, if something doesn't fit the UI, it might require an improvement in DataViews API. I think if we hit limitations in block bindings, other extenders using DataViews might hit them as well, so it could be a good way of informing those. Some of the immediate benefits I see from using DataViews:
|
a2e04f0
to
7d5af4e
Compare
I agree with @SantosGuillamot that provinding the Dataviews package would save a lot of development time and would add a default method of dealing with big amounts of data. Most sites using custom fields use at least between 5 and 10, and I consider block binding users as "advanced" developers or site builders, rather than DIYers. I may limit the the Dataviews verision to only table, and hide some sorting a rearranging options to make it simpler, but IMHO the advantages are far superior than the caveats. I've updated the branch with the last updates from DataViews team. |
@artemiomorales Thank you for the ping, otherwise I would never have known about this important ongoing experiment and conversation, and would not have been able to participate as a contributor. As mentioned a few times before, I'd kindly suggest everyone to put more focus on the established contributing guidelines of this project, otherwise this PR may look like an internal conversation between a restricted group of contributors. WordPress is supposed to be a collaborative open source project where gathering feedback from the community of contributors is essential for the health of the project. That said,
I'd tend to think making the UI show only the sources with values that are appropriate for a specific attribute should happen before any experiment about what kind of UI to use. The reason for that is that the amount of sources in the list would be greatly reduced. Would it make sense to use a big modal dialog to show, for example, only 2 sources? One more thing to consider: so far, the only available action is 'Select binding'. I'd also agree with @cbravobernal that block binding users are likely "advanced" users or site builders. For this kind of users a more complex UI shoud be manageable. But we shouldn't assume that's always true. Overall, I'd think there should be a more clear idea of how many sources will be typically listed in the UI. So far, to my understanding, the answer is that they could be a few or many, even hundreds. Would it make sense to consider two UIs?
Last considerations:
|
This has already been the case :) For example, we had identified that the actions menu could be simplified when the consumer only registered a single action and it was primary. This PR was the 2nd consumer where we saw that need, so that work was prioritized and it's now shipped. |
I appreciate that change ❤️ I would like to see that implemented for all the ellipsis menus in the editor that contain only one action. |
P.S. However, in some cases the value could be a very long string or maybe just a number. The UI should try to display these values in the most appropriate way. |
I updated this PR with that update recently.
Two UIs implies more maintenance costs, but could be an option (right now we could divide between UI with
What about if a source can be used for different attributes? Should the source definition have a list of compatible attributes?
I would love to explore that possibility. |
I also explored the combobox posibility in this PR: |
I'm not sure what would be needed from a technical side to make it work, but I'd think any source should declare what its value is intended to be used for. Also for the case of a value that can be used for more than one attribute. Still, looking at it from an UI perspective, for example displaying any |
I agree that giving greater prominence to the value makes it easier to identify and select the piece of data you're looking for. The type is mostly useful for clarification where values can be similar (e.g. image alt text / description / caption). Probably worth opening an issue for that as it may get lost here. |
993a515
to
38580df
Compare
0eb037c
to
09da201
Compare
Now custom sources without |
What?
Experiment checking how could DataViews work for post-meta and custom sources.
Right now it is hard-coded on block bindings, but I'll think about how to make it extensible. We could:
Have a DataView per source, separated by tabs.
Have a big DataView with all sources.
Demo:
dataviews_demo_mp4.mp4