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 #64631

Closed
2 tasks done
juanmaguitar opened this issue Aug 20, 2024 · 3 comments · Fixed by #64640
Closed
2 tasks done
Assignees
Labels
[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Package] DataViews /packages/dataviews [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@juanmaguitar
Copy link
Contributor

juanmaguitar commented Aug 20, 2024

Description

When no elements property is defined for any of the items passed in the fields prop, the UI still shows the filter icon but displays an empty box

Step-by-step reproduction instructions

1- Clone https://github.com/WordPress/gutenberg/ repo and install dependencies
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,
	},

2- Run npm run storybook:dev
3- Go to /?path=/story/dataviews-dataviews--default and check how the filter icon still appears and an empty box appears

The expected behaviour here would be:

  • no filter icon is displayed when no filter capabilities are given to any field

Screenshots, screen recording, code snippet

Screenshot 2024-08-20 at 08 32 17

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

cc: @oandregal

@juanmaguitar juanmaguitar added [Type] Bug An existing feature does not function as intended [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Package] DataViews /packages/dataviews labels Aug 20, 2024
@imrraaj
Copy link
Contributor

imrraaj commented Aug 20, 2024

I have created a fix for this. Creating a PR

@imrraaj
Copy link
Contributor

imrraaj commented Aug 21, 2024

I have implemented the changes. It is ready for review

@oandregal
Copy link
Member

Thanks for the report, Juanma. As per #63203 (comment) I'm going to go ahead with @imrraaj PR.

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 [Package] DataViews /packages/dataviews [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
3 participants