Skip to content

Extract choice label formatting logic into reusable utility - #9028

Merged
4ian merged 2 commits into
masterfrom
claude/mesh-label-dedup-732n7l
Aug 28, 2026
Merged

Extract choice label formatting logic into reusable utility#9028
4ian merged 2 commits into
masterfrom
claude/mesh-label-dedup-732n7l

Conversation

@4ian

@4ian 4ian commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Summary

This PR refactors the choice label formatting logic into a reusable utility function to reduce code duplication and improve maintainability.

Key Changes

  • Created new ChoiceLabel.js utility module with getChoiceDisplayLabel() function that formats choice labels by:
    • Hiding the value when the label is empty or already starts with the value
    • Displaying both value and label separated by an em-dash when they differ
  • Added comprehensive unit tests in ChoiceLabel.spec.js covering all formatting scenarios
  • Updated EventsBasedBehaviorOrObjectPropertiesEditor.js to use the new utility function
  • Updated PropertiesMapToSchema.js to use the new utility function

Implementation Details

The getChoiceDisplayLabel(value, label) function consolidates the previously duplicated logic that was inline in two different files. This improves code maintainability and ensures consistent behavior across the application when displaying choice options with optional translated labels.

https://claude.ai/code/session_0119ajoXq7k1UrzCzkuiCQYP

claude added 2 commits August 28, 2026 13:40
For example, a property choice with value "Mesh" and label
"Mesh (works for Static only)" was displayed as
"Mesh — Mesh (works for Static only)".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0119ajoXq7k1UrzCzkuiCQYP
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0119ajoXq7k1UrzCzkuiCQYP
@4ian
4ian marked this pull request as ready for review August 28, 2026 13:59
@4ian
4ian merged commit 310d61f into master Aug 28, 2026
6 of 7 checks passed
@4ian
4ian deleted the claude/mesh-label-dedup-732n7l branch August 28, 2026 14:00
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