Skip to content

Conversation

@jorgefilipecosta
Copy link
Member

Enhances the email control in DataViews with a visual @ symbol icon prefix, making email fields instantly recognizable.

Changes

  • Enhanced email control: Replaced generic ValidatedText utility with custom ValidatedInputControl implementation
  • Added @ icon prefix: Uses atSymbol icon from @wordpress/icons with proper InputControlPrefixWrapper spacing
  • Extended private APIs: Added ValidatedInputControl to components private API exports
  • Maintained functionality: Preserved all existing validation logic and field behavior

Technical Implementation

Email Control Enhancement

  • Migrated from ValidatedTextControl to ValidatedInputControl for better prefix support
  • Implemented custom validation state management with customValidity
  • Added comprehensive validation callback handling for both required and custom validation rules
  • Used InputControlPrefixWrapper with variant="icon" for optimal spacing and alignment

Icon Integration

  • Imported atSymbol icon from WordPress icons library
  • Wrapped icon in Icon component for consistent rendering
  • Applied proper spacing wrapper following established WordPress patterns
  • Maintained email input type for browser validation benefits

Test Plan

@github-actions
Copy link

github-actions bot commented Sep 5, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jorgefilipecosta <[email protected]>
Co-authored-by: oandregal <[email protected]>
Co-authored-by: ntsekouras <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@jorgefilipecosta jorgefilipecosta requested review from oandregal and removed request for ajitbohra and oandregal September 5, 2025 09:17
@jorgefilipecosta
Copy link
Member Author

If we agree with this solution I may create a new util component under the controls folder used by both email and telephone controls to make having icons easier.

);

return (
<ValidatedText
Copy link
Member

Choose a reason for hiding this comment

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

This validatedtext component was added recently to share logic among text, email, and telephone. Can we instead add a prefix in ValidatedText and update it for email and telephone?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, probably it would be better to update ValidatedText to use ValidatedInputControl instead of ValidatedTextControl. I'm not sure though if there are any nuances doing so.

In general it seems that InputControl is aimed to replace TextControl. I'll cc @ciampo for any input.

Copy link
Member

Choose a reason for hiding this comment

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

Even if text doesn't need a prefix right now (and so it could still use ValidatedText), that's something we want to open to consumers soon (see) — I've seen a few use cases already where people are using custom Edits just for the prefix.

@oandregal oandregal requested a review from ntsekouras September 5, 2025 09:25
@oandregal oandregal added [Type] Enhancement A suggestion for improvement. [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Sep 5, 2025
@github-actions
Copy link

github-actions bot commented Sep 5, 2025

Flaky tests detected in e1b5412.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17548430172
📝 Reported issues:

@jorgefilipecosta jorgefilipecosta changed the title Dataforms: Add @ icon prefix to email control Dataforms: Add icons to email and telephone controls Sep 5, 2025
@oandregal
Copy link
Member

@jorgefilipecosta #71518 just landed adding support for a new url type. Would it be too much to ask to also add a prefix for this one here? The icon would be link.

@jorgefilipecosta
Copy link
Member Author

@jorgefilipecosta #71518 just landed adding support for a new url type. Would it be too much to ask to also add a prefix for this one here? The icon would be link.

Hi @oandregal it is done 👍

jorgefilipecosta and others added 5 commits September 8, 2025 11:31
…ndividual controls

Changed approach from modifying individual form controls to enhancing the shared ValidatedText utility:
- Replaced ValidatedTextControl with ValidatedInputControl for prefix support
- Added automatic type-to-icon mapping (email → @, tel → mobile phone)
- Added optional icon prop for manual overrides
- Maintained backward compatibility while adding new capabilities

This systematic approach benefits all text-based controls and provides better maintainability.

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

Co-Authored-By: Claude <[email protected]>
Changed approach from ValidatedText automatically determining icons based on input type to individual controls explicitly passing their desired icons:

- ValidatedText: Removed getIconForType function and automatic icon imports, now only uses explicitly passed icon prop
- Email control: Added atSymbol import and explicitly passes icon prop
- Telephone control: Added mobile import and explicitly passes icon prop

This makes the icon choice more explicit and gives each control full control over its visual appearance.

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

Co-Authored-By: Claude <[email protected]>
@jorgefilipecosta jorgefilipecosta merged commit a02282b into trunk Sep 8, 2025
67 of 69 checks passed
@jorgefilipecosta jorgefilipecosta deleted the add/email-icon-prefix branch September 8, 2025 11:21
@github-actions github-actions bot added this to the Gutenberg 21.7 milestone Sep 8, 2025
</InputControlPrefixWrapper>
) : undefined
}
__next40pxDefaultSize
Copy link
Contributor

Choose a reason for hiding this comment

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

ValidatedInputControl has already this prop. I think we don't need it here.

/**
* Optional icon to display as prefix.
*/
icon?: React.ComponentType | React.ReactElement;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit late here, but wouldn't it be better if the prop is prefix and keep the flexibility of the inner component?

Why restrict to icon?

adamsilverstein pushed a commit to adamsilverstein/gutenberg that referenced this pull request Sep 11, 2025
* Add @ icon prefix to email control with proper spacing

* Refactor icon support by enhancing ValidatedText utility instead of individual controls

Changed approach from modifying individual form controls to enhancing the shared ValidatedText utility:
- Replaced ValidatedTextControl with ValidatedInputControl for prefix support
- Added automatic type-to-icon mapping (email → @, tel → mobile phone)
- Added optional icon prop for manual overrides
- Maintained backward compatibility while adding new capabilities

This systematic approach benefits all text-based controls and provides better maintainability.

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

Co-Authored-By: Claude <[email protected]>

* Refactor to explicit icon passing instead of automatic type-based icons

Changed approach from ValidatedText automatically determining icons based on input type to individual controls explicitly passing their desired icons:

- ValidatedText: Removed getIconForType function and automatic icon imports, now only uses explicitly passed icon prop
- Email control: Added atSymbol import and explicitly passes icon prop
- Telephone control: Added mobile import and explicitly passes icon prop

This makes the icon choice more explicit and gives each control full control over its visual appearance.

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

Co-Authored-By: Claude <[email protected]>

* remove unneed var

* add icon for url

* Fix unit test

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants