Skip to content

TextField and Switch/ forward id prop #2608

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

Merged
merged 3 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/switch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export type SwitchProps = {
thumbStyle?: StyleProp<ViewStyle>;
style?: StyleProp<ViewStyle>;
testID?: string;
id?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it's a leftover, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, i can open a different PR for it.. but the prop is passed to the component.
we should also type it

Copy link
Contributor

Choose a reason for hiding this comment

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

You can leave it here, please add it to the Switch's API file and I'll update the PR's changelog and name :)

}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/incubator/TextField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const TextField = (props: InternalTextFieldProps) => {
const {
modifiers,
// General
containerId,
fieldStyle: fieldStyleProp,
dynamicFieldStyle,
containerStyle,
Expand Down Expand Up @@ -123,7 +124,7 @@ const TextField = (props: InternalTextFieldProps) => {

return (
<FieldContext.Provider value={context}>
<View style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
<View id={containerId} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest changing it to containerProps to allow passing any prop the user wants to the container (of type of ViewProps without the style since we have the containerStyle prop)

<Label
label={label}
labelColor={labelColor}
Expand Down
4 changes: 4 additions & 0 deletions src/incubator/TextField/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ export type TextFieldProps = MarginModifiers &
// FieldStateProps &
ValidationMessageProps &
Omit<CharCounterProps, 'maxLength' | 'testID'> & {
/**
* Pass id to the container
*/
containerId?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

See my other comment about the name :)
Also, please put it after the containerStyle prop and also add it to the textField.api.json file (this file is for the docs site)

/**
* Pass to render a leading element
*/
Expand Down