Skip to content

Conversation

@palmerama
Copy link
Contributor

This PR fixes issue #49 by properly handling custom field types in InternationalizedField.

Changes

  • Fix custom field type rendering by properly handling props in InternationalizedField
  • Ensure custom components are preserved while maintaining internationalization features
  • Add proper type handling for field props

Problem

The issue was caused by the InternationalizedField component not properly preserving custom field components while applying internationalization features. This was preventing custom field types like markdown from rendering correctly.

Solution

This fix ensures that custom field types like markdown are rendered correctly while maintaining the plugin's internationalization functionality.

The previous implementation had issues with title hiding logic that was too simplistic and didn't properly account for language validation. This commit introduces a more robust solution that:

1. Integrates with InternationalizedArrayContext to access language configuration
2. Properly validates language IDs by checking against the configured languages
3. Only hides titles when:
   - The field is a 'value' field (title.toLowerCase() === 'value')
   - AND the field has a valid language ID that exists in the configured languages
4. Adds proper TypeScript types for language key handling
5. Simplifies the title hiding logic into a single, clear condition

The key improvement is that we now validate language IDs against the actual configured languages, ensuring that titles are only hidden for valid language entries. This prevents issues where titles might be incorrectly hidden for invalid or non-language fields.

The solution uses the InternationalizedArrayContext to access the language configuration, making it more maintainable and consistent with the rest of the plugin's architecture.
…ge validation and title hiding logic - Add proper type checking for path segments - Improve code readability and maintainability
@SimeonGriggs SimeonGriggs self-requested a review April 28, 2025 16:19
Copy link
Contributor

@SimeonGriggs SimeonGriggs left a comment

Choose a reason for hiding this comment

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

LGTM

@SimeonGriggs SimeonGriggs merged commit 4e85b95 into sanity-io:main Apr 28, 2025
9 checks passed
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