Skip to content

Commit

Permalink
fix: 修复Cell.Group的style和className作用范围不包括title的问题 #153
Browse files Browse the repository at this point in the history
  • Loading branch information
3lang3 committed Nov 12, 2021
1 parent e0f2bac commit 5549afa
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions packages/react-vant/src/cell/CellGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,22 @@ const CellGroup: React.FC<CellGroupProps> = (props) => {
const [bem] = createNamespace('cell-group', prefixCls);

const renderGroup = () => (
<div
className={classnames(
bem({ inset }),
{ [BORDER_TOP_BOTTOM]: !inset && border },
props.className,
)}
style={{ ...props.style }}
>
<div className={classnames(bem({ inset }), { [BORDER_TOP_BOTTOM]: !inset && border })}>
{props.children}
</div>
);

const renderTitle = () => <div className={classnames(bem('title'))}>{title}</div>;
const renderTitle = () => {
if (title) return <div className={classnames(bem('title'))}>{title}</div>;
return null;
};

if (title)
return (
<>
{renderTitle()}
{renderGroup()}
</>
);

return renderGroup();
return (
<div className={props.className} style={props.style}>
{renderTitle()}
{renderGroup()}
</div>
);
};

CellGroup.defaultProps = {
Expand Down

0 comments on commit 5549afa

Please sign in to comment.