Skip to content

Conversation

@pfefferle
Copy link
Member

@pfefferle pfefferle commented Nov 25, 2025

Summary

Adds object type filtering functionality to the Social Web feed sidebar, allowing users to filter feed posts by ActivityPub object types (Articles, Notes, Videos, etc.).

Screenshot 2025-11-25 at 11 22 25

(the list should normally way smaller and shows only the known types that were imported at least once)

Changes

  • Created ObjectTypes component that displays taxonomy terms as clickable filter items
  • Created useObjectTypeFilter hook to manage filter state using DataViews
  • Integrated component into sidebar navigation below the Feed menu item
  • Added icons for each object type (Articles, Music & Podcasts, Videos, etc.)
  • Added postList icon to Feed menu item
  • Configured object type field with 'is' operator for proper DataViews integration

Implementation Details

  • Object types are fetched from ap_object_type taxonomy
  • Filter uses single selection with toggle behavior (click to filter, click again to clear)
  • Selected type is highlighted in the sidebar
  • Filter button in DataViews toolbar displays the selected type name
  • Values use translated display names matching the existing filter implementation
  • Icons are 24x24 for consistency

Test Plan

  • Click object type in sidebar filters feed correctly
  • Selected type is highlighted in sidebar
  • Type filter button in toolbar shows correct label
  • Click same type again clears the filter
  • Switching between types updates both sidebar and feed

Fixes #2510

- Create useObjectTypeFilter hook to manage ap_object_type filters
- Add ObjectTypes component to display taxonomy terms in sidebar
- Integrate ObjectTypes under Feed menu item using MenuItem design
- Add postList icon to Feed menu item
- Add icons for each object type (article, audio, document, event, etc.)
- Add default icon (post) for unmapped types
- Enable toggle filtering by clicking object type names
- Fix selection highlight by manually adding is-selected class
- Use simple margin-right (8px) for icon spacing matching Gutenberg
- Use same translated names as built-in object type field
- Follow same pattern as tag filtering using view.filters
- Keep object type field filter operator as 'is' (not 'isAny')
- Update hook to use single number value instead of array
- Update useFeed hook to wrap single values in array for REST API compatibility
- Update icon sizes from 20 to 24 for both Feed menu item and object types
- This fixes the issue where the "Type" filter button in DataViews toolbar
  doesn't properly display the selected object type name
Copilot AI review requested due to automatic review settings November 25, 2025 09:45
@pfefferle pfefferle changed the base branch from trunk to add/reader November 25, 2025 09:46
Copilot finished reviewing on behalf of pfefferle November 25, 2025 09:47
@pfefferle pfefferle requested a review from obenland November 25, 2025 09:47
@pfefferle pfefferle self-assigned this Nov 25, 2025
Integrate with popular tags feature from PR #2512
- Replace isSelected prop with aria-pressed attribute following WordPress accessibility patterns
- Remove manual .is-selected class addition
- Add loading state with proper wrapper div and message
- Update CSS to handle aria-pressed='true' for selection state
- Add styling for loading state with BEM naming
- Remove default focus box-shadow and outline
- Add focus-visible for keyboard navigation only
- Use !important to override MenuItem default styles
- Keep background consistent on active/hover for selected items
- Matches WordPress core behavior
… on click

- Created useFeedFilters hook to detect active filters and clear all filters
- Feed menu item now shows as selected when no filters are active
- Clicking Feed clears all active filters (object type and tag filters)
- Disabled transitions on menu items to prevent glow/blinking effects
- Added !important to all focus/hover/active states for consistent behavior
@pfefferle pfefferle force-pushed the add/object-type-filter branch from 160b0a4 to ae8bda2 Compare November 25, 2025 10:09
The field definition was using default WordPress query parameters which limited results to 10 items. Now uses the same parameters as the sidebar component (per_page: -1, orderby: count, order: desc, hide_empty: true) to ensure all object types appear in the filter dropdown.
Filter sidebar to only display object types that have translations (Article, Audio, Document, Event, Image, Note, Page, Place, Video). Unknown types like Collection, Question, Activity, and Offer will still appear in the filter dropdown but not in the sidebar navigation.
@pfefferle
Copy link
Member Author

@obenland thanks for cleaning up the tags pr #2512 !

I tried to adapt the hooks as best as possible and brought back the icons, to better match the site-editor look and feel.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Member

@obenland obenland left a comment

Choose a reason for hiding this comment

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

Nice work!

The object types menu now displays types in the order defined by the translations object, rather than by count or default taxonomy order. Unused icons and parameters were removed for clarity.
Moved object type label and icon mapping to a shared module and updated usage in feed-stage and object-type components. This improves maintainability and consistency for object type display throughout the social web UI.
Copilot finished reviewing on behalf of pfefferle November 25, 2025 15:45
Resolves build file conflicts by regenerating after source merge.

Includes changes from add/reader:
- Content field improvements
- Object type context
- Test cleanup changes
- Updated hashtag handling in Posts collection
@pfefferle pfefferle merged commit 348148d into add/reader Nov 25, 2025
3 checks passed
@pfefferle pfefferle deleted the add/object-type-filter branch November 25, 2025 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants