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

Filter search results before showing to exclude selected items. #171

Merged
merged 1 commit into from
Nov 18, 2022

Conversation

iamdharmesh
Copy link
Member

Description of the Change

As described in #159, currently, we can pick duplicate content using ContentPicker. We already have a logic in place to exclude selected items at ContentPicker component. But this is happening because of the seachQuery cache in the ContentSearch component, the results for search keywords get stored in Object and whenever the same keyword is entered, it shows the stored results without filtering the results by excludeItems.

This PR contains a minor change for applying filterResults() on search results before showing it to prevent showing duplicated items.

Before After
Screenshot 2022-11-11 at 6 33 16 PM Screenshot 2022-11-11 at 6 32 15 PM

Closes #159

How to test the Change

  1. Checkout
  2. Run npm i && npm run build
  3. cd to example folder, run npm i && npm run build && npm run wp-env start
  4. Visit http://localhost:8888/wp-admin (user: admin, password: password)
  5. create new page/post. Add "Hello World" block.
  6. search and select content and verify it doesn't show duplicate items.

Changelog Entry

Fixed - ContentPicker can pick duplicate items before save.

Credits

Props @Firestorm980 @iamdharmesh

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@iamdharmesh iamdharmesh self-assigned this Nov 11, 2022
Copy link
Member

@fabiankaegy fabiankaegy left a comment

Choose a reason for hiding this comment

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

Thanks for this addition 🚀

@fabiankaegy fabiankaegy merged commit 231d882 into develop Nov 18, 2022
@fabiankaegy fabiankaegy deleted the fix/159 branch November 18, 2022 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ContentPicker can pick duplicate items before save
2 participants