Skip to content

Conversation

arthur791004
Copy link
Contributor

@arthur791004 arthur791004 commented Jul 3, 2025

What?

Introduce perPageSizes to control the available sizes of the items per page

image

Why?

The consumer would like to customize the number of items per page based on their layout requirements.

How?

Introduce the perPageSizes option to the view config

Testing Instructions

  • Run npm run storybook:dev to start the storybook
  • Navigate to DataViews > Custom Per Page Sizes
  • Ensure there are only 3 items
  • Open the appearance to change item per page
  • Ensure it works as expected

Testing Instructions for Keyboard

Screenshots or screencast

Before After
image image

Copy link

github-actions bot commented Jul 3, 2025

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: arthur791004 <arthur791004@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>

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

titleField: 'title',
descriptionField: 'description',
mediaField: 'image',
perPageSizes: [ 3, 6, 12, 24 ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking that this is not really a "view" configuration but more a prop of DataViews no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we already have a perPage view config—wouldn't it be better to bundle them together?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an important difference IMO. perPage impacts the layout itself, what is being rendered. So it's really the config of the "view". perPageSizes is more about the "form" that is used to configure the view, not the view itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Changed to the props of the DataViews via 48a1e90 🙂

@@ -27,6 +27,7 @@
- Add `label-position-side` classes to labels in the form field layouts. Ensure that labels in the panel view do not align center, and that all side labels are center aligned.
- Allow readonly fields in DataForm when `readOnly` is set to `true`.
- Adjust the padding when the component is placed inside a `Card`.
- Introduce `perPageSizes` to control the available sizes of the items per page
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love if we document this new prop in the README.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done by 831aa1e.

@youknowriad
Copy link
Contributor

@oandregal When you get back, I'd love a sanity check here.

For me it looks good enough.

@youknowriad youknowriad merged commit 0c9deaf into trunk Jul 7, 2025
61 of 62 checks passed
@youknowriad youknowriad deleted the DOTDASH-24/dataviews-per-page-sizes-config branch July 7, 2025 20:23
@github-actions github-actions bot added this to the Gutenberg 21.2 milestone Jul 7, 2025
@oandregal
Copy link
Member

oandregal commented Jul 31, 2025

When you get back, I'd love a sanity check here.

@youknowriad I've prepared #71004 with the things I've noticed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] DataViews /packages/dataviews [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants