gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Parent page duplicated on huge use with menu_order in dropdown

Open kent1D opened this issue 7 years ago • 9 comments

Describe the bug Context: on a website with a lot of pages on 0/1/2/3 or 4 sublevels depending on the 1st level page, using menu order on first level but also sometimes on sublevel, the dropdown duplicate some pages and doesn't show all.

Debugging:

  1. i duplicated the selector and changed the query to sort by ID, it's working fine. So to make it work change orderby menu_order to orderby id
  2. the bug is in the function "buildTermsTree" here https://github.com/WordPress/gutenberg/blob/ee6060f97fc738295f791d6a0b7633db549b39d0/packages/editor/src/utils/terms.js#L13
  3. after logging a bit it seems to be in the use of groupBy (from lodash) here: https://github.com/WordPress/gutenberg/blob/ee6060f97fc738295f791d6a0b7633db549b39d0/packages/editor/src/utils/terms.js#L14

In my tests, the param flatTerms looks fine in both cases, but termsByParent is different

To Reproduce Steps to reproduce the behavior:

  1. Create 300 pages on different sub levels
  2. Set menu order on some of them
  3. Edit a page and try to choose en parent page
  4. See what is the result

Expected behavior No duplicate content

Screenshots

capture d ecran 2018-12-11 a 13 23 18

Additional context

  • This appears in the last version of Gutenberg (4.7.0 RC and 4.6.1 on Wordpress 4.9.8 and on Wordpress 5.0)

kent1D avatar Dec 11 '18 12:12 kent1D

The best way to solve it may be to:

  • get the posts ordered by id
  • keep the menu_order in the datas here like adding order: item.menu_order,
  • use orderBy(..., 'order') from lodash to sort by menu_order then

kent1D avatar Dec 11 '18 13:12 kent1D

I am seeing this same behavior (duplicates and missing pages) with WordPress 5.0.3. We have over 500 pages. I'm not sure if order has been set on any. The parent page dropdown from within Quick Edit still works correctly.

MarkPraschan avatar Jan 31 '19 13:01 MarkPraschan

This issue was reported by a WordPress.com user with an Atomic site.

lakellie avatar Feb 06 '19 18:02 lakellie

I have the same issue too. I have a large site with over 500 pages and my issue is exactly as described above.

marjesch avatar May 12 '19 12:05 marjesch

I have the same issue. 500+ pages. It's been a year...Is WP planning to fix this or shall we give up on Gutenberg (again)?

LuckyTime154 avatar Nov 02 '19 13:11 LuckyTime154

Possibly related: #21563

talldan avatar Apr 20 '20 05:04 talldan

I also reported this problem in https://github.com/WordPress/gutenberg/issues/13618#issuecomment-567893839 and reproduced it today with Gutenberg 8.4.

See also TRAC 46294 https://core.trac.wordpress.org/ticket/46294

bobbingwide avatar Jul 01 '20 21:07 bobbingwide

Schermafbeelding 2020-10-02 om 09 52 37

I have the same issue!

DimitriDV avatar Oct 02 '20 07:10 DimitriDV

I can no longer reproduce this issue. I believe it was resolved via #25267, when the component was refactored to use combobox.

I'm going to close the issue. Feel free to reopen it with reproduction steps if you're still experiencing the problem.

Mamaduka avatar Mar 27 '25 12:03 Mamaduka