Skip to content

Commit

Permalink
Retain className for EuiFormControlLayout.prepend nodes (#2796)
Browse files Browse the repository at this point in the history
* Retain className for EuiFormControlLayout.prepend nodes

* remove dead code

* change log
  • Loading branch information
nreese authored and thompsongl committed Jan 27, 2020
1 parent 096fbfd commit 0126c53
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

- Increased column width on `EuiTableHeaderCellCheckbox` to prevent `EuiCheckbox`'s focus ring from getting clipped in `EuiBasicTable` ([#2770](https://github.com/elastic/eui/pull/2770))
- Fixed the display of `EuiButton` within `EuiControlBar` when `fill={true}` to be more consistent with other buttons ([#2781](https://github.com/elastic/eui/pull/2781))
- Fixed `EuiFormControlLayout` from overwriting className for `prepend` nodes. ([#2796](https://github.com/elastic/eui/pull/2796))

**Deprecations**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,21 @@ exports[`EuiFormControlLayout props one prepend node is rendered 1`] = `
</div>
`;

exports[`EuiFormControlLayout props one prepend node is rendered with className 1`] = `
<div
class="euiFormControlLayout euiFormControlLayout--group"
>
<span
class="euiFormControlLayout__prepend myClass"
>
1
</span>
<div
class="euiFormControlLayout__childrenWrapper"
/>
</div>
`;

exports[`EuiFormControlLayout props one prepend string is rendered 1`] = `
<div
class="euiFormControlLayout euiFormControlLayout--group"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ describe('EuiFormControlLayout', () => {
expect(component).toMatchSnapshot();
});

test('one prepend node is rendered with className', () => {
const component = render(
<EuiFormControlLayout prepend={<span className="myClass">1</span>} />
);

expect(component).toMatchSnapshot();
});

test('one prepend string is rendered', () => {
const component = render(<EuiFormControlLayout prepend="1" />);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ export class EuiFormControlLayout extends Component<EuiFormControlLayoutProps> {
key: React.Key
) {
return cloneElement(node, {
className: `euiFormControlLayout__${side}`,
className: classNames(
`euiFormControlLayout__${side}`,
node.props.className
),
key: key,
});
}
Expand Down

0 comments on commit 0126c53

Please sign in to comment.