From 42d587ddf1753149e9b0861f6ec016602d39ff98 Mon Sep 17 00:00:00 2001 From: Chandler Prall Date: Fri, 27 Apr 2018 10:24:11 -0600 Subject: [PATCH 1/2] Merge EuiTableRowCell's childClasses into any existing classNames, fixes #706 --- .../__snapshots__/table_row_cell.test.js.snap | 14 ++++++++++++++ src/components/table/table_row_cell.js | 8 +++++++- src/components/table/table_row_cell.test.js | 12 ++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/components/table/__snapshots__/table_row_cell.test.js.snap b/src/components/table/__snapshots__/table_row_cell.test.js.snap index 113bde578eb..d77cae1ddfb 100644 --- a/src/components/table/__snapshots__/table_row_cell.test.js.snap +++ b/src/components/table/__snapshots__/table_row_cell.test.js.snap @@ -42,6 +42,20 @@ exports[`align renders right when specified 1`] = ` `; +exports[`children's className merges new classnames into existing ones 1`] = ` + +
+
+
+ +`; + exports[`renders EuiTableRowCell 1`] = ` {children}; } else if(React.isValidElement(modifiedChildren)) { - modifiedChildren = React.Children.map(children, child => React.cloneElement(child, { className: childClasses })); + modifiedChildren = React.Children.map( + children, + child => React.cloneElement( + child, + { className: classNames(child.props.className, childClasses) } + ) + ); } return ( diff --git a/src/components/table/table_row_cell.test.js b/src/components/table/table_row_cell.test.js index 684ac418ee9..5df0e61fd5a 100644 --- a/src/components/table/table_row_cell.test.js +++ b/src/components/table/table_row_cell.test.js @@ -82,3 +82,15 @@ describe('truncateText', () => { expect(render(component)).toMatchSnapshot(); }); }); + +describe(`children's className`, () => { + test('merges new classnames into existing ones', () => { + const component = ( + +
+ + ); + + expect(render(component)).toMatchSnapshot(); + }); +}); From 000999f22e78f3d3f8164396d9b0416ed5f9113f Mon Sep 17 00:00:00 2001 From: Chandler Prall Date: Fri, 27 Apr 2018 10:32:31 -0600 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46b5a476d3a..2313c4c518b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ - Added `EuiEmptyPrompt` which can be used as a placeholder over empty tables and lists ([#711](https://github.com/elastic/eui/pull/711)) - Added `EuiTabbedContent` ([#737](https://github.com/elastic/eui/pull/737)) +**Bug fixes** +- Fixed `EuiTableRowCell` from overwriting its child element's `className` [#709](https://github.com/elastic/eui/pull/709) + ## [`0.0.44`](https://github.com/elastic/eui/tree/v0.0.44) - Reduced `EuiToast` title size ([#703](https://github.com/elastic/eui/pull/703))