Skip to content

Conversation

@bokelley
Copy link
Contributor

@bokelley bokelley commented Nov 3, 2025

Summary

Improves the targeting selector UX by alphabetizing both keys and values, and displaying human-readable names instead of IDs in the selected targeting badges.

Changes

1. Alphabetize Targeting Keys

Added sorting after fetching keys:

// Sort keys alphabetically by display name
availableKeys.sort((a, b) => {
    const nameA = (a.display_name || a.name).toLowerCase();
    const nameB = (b.display_name || b.name).toLowerCase();
    return nameA.localeCompare(nameB);
});

2. Alphabetize Targeting Values

Added sorting after fetching values:

// Sort values alphabetically by display name
const sortedValues = [...data.values].sort((a, b) => {
    const nameA = (a.display_name || a.name).toLowerCase();
    const nameB = (b.display_name || b.name).toLowerCase();
    return nameA.localeCompare(nameB);
});

3. Show Display Names in Selected Targeting

Before: iabctax: IAB20 (showed IDs)
After: IAB Content: Travel (shows readable names)

Implementation:

  • Store display names separately in window.targetingDisplayNames
  • Track both key and value display names when selecting
  • Render badges using display names with fallback to internal names
  • Handle existing targeting data by building display name mappings

Benefits

  • Easier to find: Keys and values appear in alphabetical order
  • Readable: Selected targeting shows "IAB Content: Travel" instead of "iabctax: IAB20"
  • Consistent: Same sorting behavior in both product page and targeting browser
  • Intuitive: Users see friendly names throughout the flow

Before/After

Dropdown Order

Before: Random order from API (Mac Support, Net for Beginners, Palmtops/PDAs, Entertainment, Visual Basic, Web Search, Travel...)
After: Alphabetical order (Entertainment, Mac Support, Net for Beginners, Palmtops/PDAs, Travel, Visual Basic, Web Search...)

Selected Display

Before: iabctax: IAB20 (ID-based)
After: IAB Content: Travel (human-readable)

Test plan

  • Load product add/edit page
  • Verify targeting keys dropdown is alphabetized
  • Select a key and verify values dropdown is alphabetized
  • Select values and verify badges show display names (not IDs)
  • Load targeting browser and verify keys list is alphabetized
  • Search for keys - verify filtered results are still alphabetized
  • All tests pass (861 unit, 32 integration, 28 integration_v2)

🤖 Generated with Claude Code

bokelley and others added 2 commits November 3, 2025 12:20
Sort targeting keys alphabetically by display name for better UX:
- Product page targeting selector dropdown
- Targeting browser keys list

Uses case-insensitive sorting with localeCompare for proper
alphabetical ordering. Applied consistently across both UIs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fixed three issues with the targeting value selection:

1. **Alphabetize values**: Sort values alphabetically by display_name
   before populating the dropdown for easier selection

2. **Show display names**: Display human-readable names instead of IDs
   in the selected targeting badges (e.g., "IAB Content: Travel" instead
   of "iabctax: IAB20")

3. **Consistent format**: Both key and value now show display names with
   fallback to internal names if display name not available

Implementation:
- Sort values using localeCompare after fetching from API
- Store display names separately in window.targetingDisplayNames
- Lookup display names when rendering selected targeting badges
- Handle existing targeting data by building display name mappings

Fixes: Selected targeting showing IDs instead of readable names

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@bokelley bokelley changed the title feat: alphabetize custom targeting keys in dropdowns and lists feat: alphabetize targeting keys/values and show display names Nov 3, 2025
@bokelley bokelley merged commit c6be06d into main Nov 3, 2025
10 checks passed
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
…textprotocol#687)

* feat: alphabetize custom targeting keys in dropdowns and lists

Sort targeting keys alphabetically by display name for better UX:
- Product page targeting selector dropdown
- Targeting browser keys list

Uses case-insensitive sorting with localeCompare for proper
alphabetical ordering. Applied consistently across both UIs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix: alphabetize values and show display names in targeting selector

Fixed three issues with the targeting value selection:

1. **Alphabetize values**: Sort values alphabetically by display_name
   before populating the dropdown for easier selection

2. **Show display names**: Display human-readable names instead of IDs
   in the selected targeting badges (e.g., "IAB Content: Travel" instead
   of "iabctax: IAB20")

3. **Consistent format**: Both key and value now show display names with
   fallback to internal names if display name not available

Implementation:
- Sort values using localeCompare after fetching from API
- Store display names separately in window.targetingDisplayNames
- Lookup display names when rendering selected targeting badges
- Handle existing targeting data by building display name mappings

Fixes: Selected targeting showing IDs instead of readable names

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants