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

Enhance <TextInputRow> for custom rendering and textarea autosizing #203

Merged
merged 5 commits into from
Mar 25, 2019

Conversation

tz5514
Copy link
Contributor

@tz5514 tz5514 commented Mar 25, 2019

Purpose

Enhance <TextInputRow> for custom rendering and textarea autosizing.

Changes

Changed

  • [Form] Enhance <TextInputRow>:
    • Can render custom input by renderInput or inputComponent prop.
    • Can specify textarea autosize rules by minRows and maxRows props.

Risk

none.

TODOs

none.

@tz5514 tz5514 self-assigned this Mar 25, 2019
@tz5514 tz5514 requested review from zhusee2, hsunpei and chenesan March 25, 2019 07:32
{...sharedProps}
{...inputProps} />
return React.createElement(
isFunction(inputComponent) ? inputComponent : 'input',
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can just set default value of 'input' to props.inputComponent? And allow it to be either a String or a Function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds great!

{...sharedProps}
{...inputProps} />
);
if (isFunction(renderInput)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if it's used this way:

<TextInputRow
    multiLine
    renderInput={func}
/>

Do you intent to let renderInput overridden by multiLine?

Copy link
Contributor Author

@tz5514 tz5514 Mar 25, 2019

Choose a reason for hiding this comment

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

No, input can't be customized when multiLine mode.

expect(controlledWrapper.find('textarea').prop('style')).toEqual({ height: 60 });
const textareaWrapper = uncontrolledWrapper.find(AutoSizeTextarea);
expect(textareaWrapper.exists()).toBeTruthy();
expect(textareaWrapper.props()).toMatchObject({ minRows: 5, maxRows: 10 });
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 nice shallow testing

Copy link
Contributor

@zhusee2 zhusee2 left a comment

Choose a reason for hiding this comment

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

Others look great to me 💯

@tz5514 tz5514 merged commit 8327f8f into develop Mar 25, 2019
@zhusee2 zhusee2 deleted the feature/enhance_text_input_row branch April 11, 2019 04:24
@zhusee2 zhusee2 added this to the 3.0.x milestone May 9, 2019
@zhusee2 zhusee2 mentioned this pull request May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants