-
Notifications
You must be signed in to change notification settings - Fork 23
feat(text-field): accept exceptionallySetClassName on the input element #1047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,13 +8,15 @@ import { Box } from '../box' | |
| import styles from './text-field.module.css' | ||
|
|
||
| import type { BaseFieldProps, BaseFieldVariantProps, FieldComponentProps } from '../base-field' | ||
| import type { ObfuscatedClassName } from '../utils/common-types' | ||
|
|
||
| type TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url' | ||
|
|
||
| interface TextFieldProps | ||
| extends Omit<FieldComponentProps<HTMLInputElement>, 'type' | 'supportsStartAndEndSlots'>, | ||
| BaseFieldVariantProps, | ||
| Pick<BaseFieldProps, 'characterCountPosition'> { | ||
| Pick<BaseFieldProps, 'characterCountPosition'>, | ||
| ObfuscatedClassName { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Extending |
||
| type?: TextFieldType | ||
| startSlot?: React.ReactElement | string | number | ||
| endSlot?: React.ReactElement | string | number | ||
|
|
@@ -45,6 +47,7 @@ const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function Te | |
| onChange: originalOnChange, | ||
| characterCountPosition = 'below', | ||
| endSlotPosition = 'bottom', | ||
| exceptionallySetClassName, | ||
| ...props | ||
| }, | ||
| ref, | ||
|
|
@@ -107,6 +110,7 @@ const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function Te | |
| type={type} | ||
| ref={combinedRef} | ||
| maxLength={maxLength} | ||
| className={exceptionallySetClassName} | ||
| onChange={(event) => { | ||
| originalOnChange?.(event) | ||
| onChange?.(event) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Using
data-testidmay target the field's wrapper instead of the underlying<input>element, which undermines the test's intent to verify exactly where the class lands. To guarantee you are asserting on the input element itself (and to follow the project's testing conventions), query by role instead.You can then safely remove the
data-testidprop from theTextFieldon line 245.