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

Bug: duplicate key when using QueryControls with categorySuggestions #49515

Open
hastinbe opened this issue Mar 31, 2023 · 2 comments
Open

Bug: duplicate key when using QueryControls with categorySuggestions #49515

hastinbe opened this issue Mar 31, 2023 · 2 comments
Labels
[Block] Latest Posts Affects the Latest Posts Block [Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Comments

@hastinbe
Copy link

There are 2 separate but related issues here.

QueryControls component

The category name is used when defining the key, because those are not unique when you have multiple categories with the same name you'll get duplicate keys and UI side effects where you cannot remove the duplicate tokens in the Editor.

For reference:

value: item.name || item.value,

<FlexItem key={ 'token-' + _value }>

Latest Posts block

This also affects the Latest Posts component in a couple ways. The first is not directly related to the above problem, but it is unable to display categories with the same names as suggestions because it too uses the non-unique name as seen here:

[ category.name ]: category,

To reproduce:

  • Create 2 categories with the same name.
  • Start a new page in the editor and add the Latests Posts block
  • Try to select your categories with the same name, only 1 will display as a suggestion
@mrfoxtalbot mrfoxtalbot added [Type] Bug An existing feature does not function as intended Needs Testing Needs further testing to be confirmed. [Block] Latest Posts Affects the Latest Posts Block [Block] Query Loop Affects the Query Loop Block labels Apr 1, 2023
@mrfoxtalbot
Copy link

Thank you for reporting this @hastinbe. Could you please confirm if this bug was introduced with the latest 6.2 release or is this something you noticed before the update?

Also, could you please share more details on how you go about creating two terms with the same name in the first place? I tried this and neither the editor nor wp-admin/edit-tags.php will let me create a term with a duplicated name for a given taxonomy.

Thank you!

@hastinbe
Copy link
Author

hastinbe commented Apr 1, 2023

Sure, all you need to do is set a parent for the term. Sorry I should have explained that in the reproduce section of my post. I'm almost sure it happened before 6.2 as I recall upgrading to 6.2 after encountering the issue

output

@t-hamano t-hamano added [Package] Components /packages/components and removed Needs Testing Needs further testing to be confirmed. [Block] Query Loop Affects the Query Loop Block labels Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Latest Posts Affects the Latest Posts Block [Package] Components /packages/components [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants