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: SimpleFormIterator clear item call action #8302

Merged
merged 5 commits into from
Nov 27, 2022

Conversation

Seojun-Park
Copy link
Contributor

@Seojun-Park Seojun-Park commented Oct 25, 2022

This PR is related to this issue : #8287

Screen.Recording.2022-10-25.at.12.21.05.mov

@WiXSL
Copy link
Contributor

WiXSL commented Oct 25, 2022

This looks really good!
It is necessary for us that you add some unit tests and at least a story to showcase the new feature
Plus, since is a new feature, you have to target it from next branch instead of master

@Seojun-Park Seojun-Park changed the base branch from master to next October 25, 2022 15:44
@Seojun-Park
Copy link
Contributor Author

Seojun-Park commented Oct 25, 2022

Target is changed to next and story test is added

Thanks!

@WiXSL
Copy link
Contributor

WiXSL commented Oct 25, 2022

Could you rebase?

@Seojun-Park
Copy link
Contributor Author

@WiXSL

I'm asking this just to be sure :)
do you want me to rebase to next branch?

@WiXSL
Copy link
Contributor

WiXSL commented Oct 25, 2022

Sure, right now, your history shows changes in 61 files. It is difficult to follow

@WiXSL
Copy link
Contributor

WiXSL commented Oct 25, 2022

You've added a story for storybook, but you need to add unit tests as well and documentation

@fzaninotto
Copy link
Member

Hi, and thanks for your PR.

I'm not fond of the UI you're proposing. The "refresh" icon is misleading in this case, and the icon color should be the same as the 'remove item' icon since it's a destructive action.

@Seojun-Park Seojun-Park requested review from soullivaneuh, WiXSL and fzaninotto and removed request for WiXSL, soullivaneuh and fzaninotto November 23, 2022 09:06
@@ -70,6 +70,7 @@ const OrderEdit = () => (
| Prop | Required | Type | Default | Description |
|----------|----------|----------------|-----------------------|-------------------------------------|
| `addButton` | Optional | `ReactElement` | - | Component to render for the add button |
| `clearButton` | Optional | `boolean` | `true` | When `false`, the user cannot clear the array |
Copy link
Member

Choose a reason for hiding this comment

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

If it's a simple boolean, then the prop name isn't right.

In general, we prefer to define boolean props that take the value true when used, so:

<SimpleFormIterator disableClear>

is preferable to:

<SimpleFormIterator clearButton={false}>

In addition, we already have other disableXXX props for this component, so for consistency this prop should follow the same pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated : b987e62

@@ -94,6 +95,10 @@ This prop lets you pass a custom element to replace the default Add button.
</SimpleFormIterator>
```

## `clearButton`

This prop lets you pass a custom element to replace the default "Clear the list" button
Copy link
Member

Choose a reason for hiding this comment

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

That's not true anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed and disableClear description is added : b987e62

Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

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

Almost there!

</div>
)}
<div className={SimpleFormIteratorClasses.buttons}>
{!disabled && !disableAdd && (
Copy link
Member

Choose a reason for hiding this comment

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

In the DisableAdd story, I see that this also disables the ClearButton...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, disableAdd condition should not effect to disableClear

resolve commit : 2f21d4d

</div>
)}
<div className={SimpleFormIteratorClasses.buttons}>
{!disabled && (
Copy link
Member

Choose a reason for hiding this comment

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

But then if both disableAdd and disableRemove are true, we will insert an empty div for nothing...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

empty div should not render, I agree

resolve commit : 2646756

While doing this, I realized that array clear button has add suffix on classname. I guess the each button's class name should have relate to the its behavior.
I added poc commit for verification : dd187c5

@fzaninotto
Copy link
Member

Thanks

@fzaninotto fzaninotto added this to the 4.6 milestone Nov 27, 2022
@fzaninotto fzaninotto merged commit 4487b6e into marmelab:next Nov 27, 2022
@Seojun-Park Seojun-Park deleted the array-clear-button branch November 28, 2022 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants