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 all commits
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/components/switch/switch.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
{"name": "thumbSize", "type": "number", "description": "The Switch's thumb size (width & height)"},
{"name": "thumbStyle", "type": "ViewStyle", "description": "The Switch's thumb style"},
{"name": "style", "type": "ViewStyle", "description": "Custom style"},
{"name": "testID", "type": "string", "description": "Component test id"}
{"name": "testID", "type": "string", "description": "Component test id"},
{"name": "id", "type": "string", "description": "Component id"}
],
"snippet": [
"<Switch value={false$1} onValueChange={() => console.log('value changed')$2}/>"
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
containerProps,
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 {...containerProps} style={[margins, positionStyle, containerStyle, centeredContainerStyle]}>
<Label
label={label}
labelColor={labelColor}
Expand Down
1 change: 1 addition & 0 deletions src/incubator/TextField/textField.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"type": "ViewStyle | (context: FieldContextType, props) => ViewStyle",
"description": "Internal style for the field container to style the field underline, outline and fill color"
},
{"name": "containerProps", "type": "Omit<ViewProps, 'style'>", "description": "Container props of the whole component"},
{"name": "containerStyle", "type": "ViewStyle", "description": "Container style of the whole component"},
{
"name": "preset",
Expand Down
5 changes: 5 additions & 0 deletions src/incubator/TextField/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '../../commons/new';
import {TextProps} from '../../components/text';
import {PropsWithChildren, ReactElement} from 'react';
import {ViewProps} from '../../components/view';

export type ColorType =
| string
Expand Down Expand Up @@ -216,6 +217,10 @@ export type TextFieldProps = MarginModifiers &
* Internal dynamic style callback for the field container
*/
dynamicFieldStyle?: (context: FieldContextType, props: {preset: TextFieldProps['preset']}) => StyleProp<ViewStyle>;
/**
* Pass props to the container
*/
containerProps?: Omit<ViewProps, 'style'>;
/**
* Container style of the whole component
*/
Expand Down