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

DataViews: make the move left/right controls in table header always available #64646

Merged
merged 4 commits into from
Aug 20, 2024

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Aug 20, 2024

What?

Introduce a enableMoving that controls whether the "move to left"/"move to right" controls are visible in the table layout:

Captura de ecrã 2024-08-20, às 16 28 23

Why?

Without this setting, the visibility of those controls depends on the other conditions:

  • enableHiding: if the "hide column" option is displayed. true by default.
  • enableSorting: if the sort options are displayed. true by default.
  • If the field has a filter defined, it'll display the "add filter".

There are situations where the field can be hidden, it's not sortable, and doesn't have a filter, but we still want to display the move left/right controls.

How?

Introduce a new enableMoving setting to the fields API. It's true by default.

Testing Instructions

Nothing changes in terms of UI.

For testing the feature, go to the post-fields configuration and set the title field to enableSorting: false. Reload and verify that the table header controls are still displayed:

Captura de ecrã 2024-08-20, às 17 15 42

@oandregal oandregal self-assigned this Aug 20, 2024
Copy link

github-actions bot commented Aug 20, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: oandregal <[email protected]>
Co-authored-by: youknowriad <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@oandregal oandregal added [Type] Enhancement A suggestion for improvement. [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Aug 20, 2024
@youknowriad
Copy link
Contributor

I'm kind of curious, why would we want to disable moving for a field. Also disabling moving for a field doesn't mean it can't move if you can move the fields around it. So I'm failing to see why we need this API personally.

@oandregal
Copy link
Member Author

oandregal commented Aug 20, 2024

I'm kind of curious, why would we want to disable moving for a field. Also disabling moving for a field doesn't mean it can't move if you can move the fields around it. So I'm failing to see why we need this API personally.

I want to prevent the opposite: it'll be hidden if we disable sorting & "is hidden". There are valid cases where those two can be disabled but we still want the "move tools" to be available. Without this PR, it'd be hidden.

An alternative would be to make it always available. That would work for me but I want to prevent cases where consumers use hacky ways to hide this control: providing it as an API helps them to tweak DataViews in a proper way.

@oandregal
Copy link
Member Author

Riad and I talked about this and I'm going to prepare the alternative: make the "moving controls always available". There should also be a drag&drop or arrows in the properties section of the view config that it's related to this.

If it comes to making this configurable, it perhaps makes more sense to enable/disable at the view level rather than the field level.

@oandregal
Copy link
Member Author

Pushed the alternative.

@oandregal oandregal changed the title DataViews: introduce enableMoving to field API DataViews: make the move left/right controls in table header always available Aug 20, 2024
@youknowriad
Copy link
Contributor

Something slightly related that we're missing is that the "combined fields" doesn't support this dropdown menu yet. (Can be done later)

@youknowriad
Copy link
Contributor

Maybe we can mention this in the changelog.

@oandregal oandregal enabled auto-merge (squash) August 20, 2024 15:22
@oandregal oandregal merged commit b1324c5 into trunk Aug 20, 2024
60 checks passed
@oandregal oandregal deleted the update/dataviews-is-movable branch August 20, 2024 15:57
@github-actions github-actions bot added this to the Gutenberg 19.1 milestone Aug 20, 2024
bph pushed a commit to bph/gutenberg that referenced this pull request Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants