-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Add <SingleFieldList empty gap direction>
props, and allow it to be used without children
#9439
Conversation
{cloneElement(Children.only(children), { | ||
record, | ||
resource, | ||
// Workaround to force ChipField to be clickable | ||
onClick: handleClick, | ||
})} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is technically a BC break, as people may use SingleFieldList with children expecting record
as prop. However, it's not supposed to be the case since 4.0.
@@ -174,7 +181,11 @@ const Root = styled('div', { | |||
// useful to prevent click bubbling in a datagrid with rowClick | |||
const stopPropagation = e => e.stopPropagation(); | |||
|
|||
// Our handleClick does nothing as we wrap the children inside a Link but it is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We no longer need this: the default child uses the clickable
prop only when necessary. And when developers pass a custom child, they'll have to set the clickable
themselves if they want. In that case, this PR is a slight BC break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm mistaken, until now developers always had to pass a child. So it's a BC for everyone using <SingleFieldList>
right now unless they have specifically disabled the link.
I agree it's a very minor BC, but it will still impact almost everyone using <SingleFieldList>
right now. Maybe we should insist on it more in the docs and/or the changelog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I updated the PR description, and we should include the "Minor BC break" section in the release changelog.
linkType = 'edit', | ||
component: Component = Root, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
component
is now passed down to <Stack>
, which knows how to handle it.
<SingleFieldList empty>
prop to customize empty value<SingleFieldList>
to make it more powerful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than that, it works great! 🎉
And the stories are very helpful.
@@ -174,7 +181,11 @@ const Root = styled('div', { | |||
// useful to prevent click bubbling in a datagrid with rowClick | |||
const stopPropagation = e => e.stopPropagation(); | |||
|
|||
// Our handleClick does nothing as we wrap the children inside a Link but it is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm mistaken, until now developers always had to pass a child. So it's a BC for everyone using <SingleFieldList>
right now unless they have specifically disabled the link.
I agree it's a very minor BC, but it will still impact almost everyone using <SingleFieldList>
right now. Maybe we should insist on it more in the docs and/or the changelog?
<SingleFieldList>
to make it more powerful<SingleFieldList empty gap direction>
props, and allow it to be used without children
Problems
<SingleFieldList>
has many issues:<ChipField>
Stack
, except it's not aStack
empty
propSolution
<SingleFieldList>
now renders a real<Stack>
, and supports all its props<SingleFieldList>
used without children renders a<ChipField>
with therecordRepresentation
<SingleFieldList>
supports anempty
propCloses #7634
Minor BC Break
If you used
<SingleFieldList>
with a<ChipField>
child and enabled the links, the chips background will no longer change on hover. To reenable this visual effect, add theclickable
prop to the<ChipField>
:Alternately, if the
<ChipField source>
is the same as the resource'srecordRepresentation
, you can omit the child altogether.