Parent page duplicated on huge use with menu_order in dropdown
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:
- 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
- the bug is in the function "buildTermsTree" here https://github.com/WordPress/gutenberg/blob/ee6060f97fc738295f791d6a0b7633db549b39d0/packages/editor/src/utils/terms.js#L13
- 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:
- Create 300 pages on different sub levels
- Set menu order on some of them
- Edit a page and try to choose en parent page
- See what is the result
Expected behavior No duplicate content
Screenshots

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)
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
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.
This issue was reported by a WordPress.com user with an Atomic site.
I have the same issue too. I have a large site with over 500 pages and my issue is exactly as described above.
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)?
Possibly related: #21563
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

I have the same issue!
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.