Skip to content
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

feat(multiline-text-field): Add maxRows prop #3033

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .changeset/tall-foxes-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-uikit/multiline-text-field': patch
---

Adds `maxRows` prop to MultilineTextField.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default Example;
| `onInfoButtonClick` | `Function`<br/>[See signature.](#signature-onInfoButtonClick) | | | Function called when info button is pressed.&#xA;<br />&#xA;Info button will only be visible when this prop is passed. |
| `hintIcon` | `ReactElement` | | | Icon to be displayed beside the hint text.&#xA;<br />&#xA;Will only get rendered when `hint` is passed as well. |
| `badge` | `string` | | | Badge to be displayed beside the label.&#xA;<br />&#xA;Might be used to display additional information about the content of the field (E.g verified email) |
| `maxRows` | `number` | | | Set this to value to determine the maximum text rows of the text area.&#xA;Any text overflow past this row number would implement a scroll |

## Signatures

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ export type TMultiTextFieldProps = {
* Might be used to display additional information about the content of the field (E.g verified email)
*/
badge?: string;
/**
* Set this to value to determine the maximum text rows of the text area.
* Any text overflow past this row number would implement a scroll
*/
maxRows?: number;
};

type TState = {
Expand Down Expand Up @@ -253,6 +258,7 @@ class MultilineTextField extends Component<TMultiTextFieldProps, TState> {
hasWarning={hasWarning}
placeholder={this.props.placeholder}
horizontalConstraint="scale"
maxRows={this.props.maxRows}
{...filterDataAttributes(this.props)}
aria-invalid={hasError}
aria-errormessage={errorsContainerId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ export const component = () => (
renderWarning={() => 'Custom warning'}
/>
</Spec>
<Spec label="with max rows">
<MultilineTextField
title="Welcome Text"
value={value}
onChange={() => {}}
horizontalConstraint={7}
maxRows={3}
/>
</Spec>
{/* <Spec label="when expanded by default">
<MultilineTextField
title="Welcome Text"
Expand Down