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: Filter icon is displayed even when no filter capabilities are given to any field #64640

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

imrraaj
Copy link
Contributor

@imrraaj imrraaj commented Aug 20, 2024

What?

This fix hides the dropdown button when there are no filter option available to choose from

Why?

Fixes #64631

How?

Added a check if filters are available, if not then return null

Testing Instructions

  1. Clone the repo
  2. Edit packages/dataviews/src/components/dataviews/stories/fixtures.js and comment on any elements or filterBy properties passed in the items passed to the fields props
{
		label: 'Type',
		id: 'type',
		enableHiding: false,
		// elements: [
		// 	{ value: 'Not a planet', label: 'Not a planet' },
		// 	{ value: 'Ice giant', label: 'Ice giant' },
		// 	{ value: 'Terrestrial', label: 'Terrestrial' },
		// 	{ value: 'Gas giant', label: 'Gas giant' },
		// ],
},
{
		label: 'Categories',
		id: 'categories',
		// elements: [
		// 	{ value: 'Space', label: 'Space' },
		// 	{ value: 'NASA', label: 'NASA' },
		// 	{ value: 'Planet', label: 'Planet' },
		// 	{ value: 'Solar system', label: 'Solar system' },
		// 	{ value: 'Ice giant', label: 'Ice giant' },
		// ],
		// filterBy: {
		// 	operators: [ 'isAny', 'isNone', 'isAll', 'isNotAll' ],
		// },
		getValue: ( { item } ) => {
			return item.categories;
		},
		render: ( { item } ) => {
			return item.categories.join( ',' );
		},
		enableSorting: false,
},
  1. Run npm run storybook:dev
  2. Go to /?path=/story/dataviews-dataviews--default and check how the filter icon no longer appears

Testing Instructions for Keyboard

Screenshots or screencast

Screenshot 2024-08-20 at 3 31 48 PM The dropdown button is no longer visible when there are no filter options

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @raj.patel@rtcamp.com.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: raj.patel@rtcamp.com.

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: imrraaj <imrraaj@git.wordpress.org>
Co-authored-by: juanmaguitar <juanmaguitar@git.wordpress.org>

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

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Aug 20, 2024
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @imrraaj! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@imrraaj imrraaj changed the title Check if filters exists or not when rendering the dropdown button Dataviews: Filter icon is displayed even when no filter capabilities are given to any field Aug 20, 2024
@oandregal oandregal added [Type] Bug An existing feature does not function as intended [Feature] Data Views Work surrounding upgrading and evolving views in the site editor and beyond labels Aug 21, 2024
@oandregal
Copy link
Member

Thanks for your contribution, @imrraaj!

@oandregal oandregal merged commit f971fbf into WordPress:trunk Aug 21, 2024
66 checks passed
@github-actions github-actions bot added this to the Gutenberg 19.1 milestone Aug 21, 2024
bph pushed a commit to bph/gutenberg that referenced this pull request Aug 31, 2024
Unlinked contributors: raj.patel@rtcamp.com.

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: imrraaj <imrraaj@git.wordpress.org>
Co-authored-by: juanmaguitar <juanmaguitar@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Data Views Work surrounding upgrading and evolving views in the site editor and beyond First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dataviews: Filter icon is displayed even when no filter capabilities are given to any field
2 participants