Skip to content

Add linkable items dropdown data for navigation menus#22558

Merged
nbradbury merged 10 commits intotrunkfrom
issue/menus-linkable-items
Feb 5, 2026
Merged

Add linkable items dropdown data for navigation menus#22558
nbradbury merged 10 commits intotrunkfrom
issue/menus-linkable-items

Conversation

@nbradbury
Copy link
Copy Markdown
Contributor

@nbradbury nbradbury commented Feb 4, 2026

Description

Partially addresses CMM-1166 by implementing the dropdown data loading for the menu item type selection in the navigation menus feature:

  • Posts: Fetches up to 20 posts, sorted by date (newest first)
  • Pages: Fetches up to 20 pages, sorted by date (newest first)
  • Categories: Fetches up to 20 categories, sorted alphabetically (A-Z)
  • Tags: Fetches up to 20 tags, sorted alphabetically (A-Z)

Uses wordpress-rs networking library (not FluxC) with the following endpoints:

  • posts().listWithEditContext() with PostEndpointType.Posts / PostEndpointType.Pages
  • terms().listWithEditContext() with TermEndpointType.Categories / TermEndpointType.Tags

Also updates the dropdown placeholder text to be type-specific (e.g., "Select a post" instead of generic "Select an item").

Limitations

  • Pagination will come later
  • Saving any menu item other than a "Custom link" will fail

Test plan

Menu item type dropdown:

  1. Open a site with navigation menus enabled
  2. Navigate to a menu and tap "Add Item"
  3. Select "Post" from the Type dropdown
  • Verify dropdown shows "Select a post" placeholder
  • Verify posts load and are sorted by date (newest first)
  1. Select "Page" from the Type dropdown
  • Verify dropdown shows "Select a page" placeholder
  • Verify pages load and are sorted by date (newest first)
  1. Select "Category" from the Type dropdown
  • Verify dropdown shows "Select a category" placeholder
  • Verify categories load and are sorted alphabetically
  1. Select "Tag" from the Type dropdown
  • Verify dropdown shows "Select a tag" placeholder
  • Verify tags load and are sorted alphabetically
  1. Select an item from any dropdown
  • Verify the item title auto-fills
linked-items.mp4

nbradbury and others added 4 commits February 4, 2026 15:58
Implements linkable items fetching for the navigation menus feature:
- Add fetchCategories() and fetchTags() methods to NavMenuRestClient
- Categories and tags are sorted alphabetically (A-Z) and limited to 20 items
- Update NavMenusViewModel to load items when menu item type changes
- Posts and pages support pending wordpress-rs API availability

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements fetching posts and pages for menu item linking:
- Add fetchPosts() using posts().listWithEditContext() with PostEndpointType.Posts
- Add fetchPages() using posts().listWithEditContext() with PostEndpointType.Pages
- Posts and pages are sorted by date (newest first) and limited to 20 items
- Update ViewModel to call the new methods when POST or PAGE type is selected

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changes the "Select an item" placeholder to be type-specific:
- "Select a post" for posts
- "Select a page" for pages
- "Select a category" for categories
- "Select a tag" for tags

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Renames result types for better naming consistency:
- NavMenusResult → NavMenuListResult
- NavMenuItemsResult → NavMenuItemListResult

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dangermattic
Copy link
Copy Markdown
Collaborator

dangermattic commented Feb 4, 2026

1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

When a post, page, category, or tag is selected from the dropdown,
always update the title field with the item's title instead of only
setting it when the title is blank.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@nbradbury nbradbury added the Menus label Feb 4, 2026
nbradbury and others added 2 commits February 4, 2026 16:38
- Rename test to reflect that title is always set from selected item
- Add test verifying title is replaced even when already filled
- Add test verifying loading state is set when changing to non-custom type
- Add lenient mocks for linkable items fetch methods

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extract common logic for fetching linkable items into private helper
methods:
- fetchPostType() for posts and pages (sorted by date descending)
- fetchTermType() for categories and tags (sorted alphabetically)

This addresses the SonarCloud code duplication warning.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@nbradbury

This comment was marked as outdated.

@claude

This comment was marked as resolved.

nbradbury and others added 3 commits February 4, 2026 16:54
Extract specific error messages from WpRequestResult variants instead
of returning generic messages. The WpError variant now passes through
the actual API error message when available, improving debugging for
users and developers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Linkable items (posts, pages, categories, tags) are flat lists without
hierarchy, so indentLevel and related accessibility descriptions were
incorrectly applied. This removes:
- indentLevel property from LinkableItemOption data class
- Unnecessary accessibility description in LinkableItemDropdown
- Unnecessary indent-based padding in LinkableItemDropdown

Parent items correctly retain indentLevel as they have hierarchy.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Some posts/pages may have an empty raw title but a valid rendered
title. This ensures dropdown items always show a title when available.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Feb 4, 2026

@wordpress-mobile wordpress-mobile deleted a comment from claude bot Feb 4, 2026
@wpmobilebot
Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
FlavorJalapeno
Build TypeDebug
Versionpr22558-9a6cb6a
Build Number1483
Application IDcom.jetpack.android.prealpha
Commit9a6cb6a
Installation URL030qgshrvk7rg
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
FlavorJalapeno
Build TypeDebug
Versionpr22558-9a6cb6a
Build Number1483
Application IDorg.wordpress.android.prealpha
Commit9a6cb6a
Installation URL6pveeqhcsacsg
Note: Google Login is not supported on these builds.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 12.28070% with 100 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.24%. Comparing base (99094d5) to head (9a6cb6a).
⚠️ Report is 2 commits behind head on trunk.

Files with missing lines Patch % Lines
...ress/android/ui/navmenus/data/NavMenuRestClient.kt 2.77% 70 Missing ⚠️
...wordpress/android/ui/navmenus/NavMenusViewModel.kt 34.37% 14 Missing and 7 partials ⚠️
...ndroid/ui/navmenus/screens/MenuItemDetailScreen.kt 0.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #22558      +/-   ##
==========================================
- Coverage   38.25%   38.24%   -0.02%     
==========================================
  Files        2237     2237              
  Lines      111007   111084      +77     
  Branches    15519    15537      +18     
==========================================
+ Hits        42467    42479      +12     
- Misses      65007    65067      +60     
- Partials     3533     3538       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nbradbury nbradbury marked this pull request as ready for review February 4, 2026 22:32
@nbradbury nbradbury requested a review from adalpari February 4, 2026 22:32
Copy link
Copy Markdown
Contributor

@adalpari adalpari left a comment

Choose a reason for hiding this comment

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

LGTM!

@nbradbury nbradbury merged commit 275e518 into trunk Feb 5, 2026
27 of 35 checks passed
@nbradbury nbradbury deleted the issue/menus-linkable-items branch February 5, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants