Skip to content

Commit 415cee8

Browse files
authored
Honoring className prop (#3300)
* Honoring className prop * Update entry * Add snapshot
1 parent f9b929c commit 415cee8

File tree

6 files changed

+52
-6
lines changed

6 files changed

+52
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4040
- Remove `tabindex="-1"` from Adaptive Cards container
4141
- Hide activities of type `invoke`
4242
- Fixes [#3294](https://github.com/microsoft/BotFramework-WebChat/issues/3294). Fix blank screen on missing middlewares, by [@compulim](https://github.com/compulim) in PR [#3295](https://github.com/microsoft/BotFramework-WebChat/pull/3295)
43+
- Fixes [#3297](https://github.com/microsoft/BotFramework-WebChat/issues/3297). Fix `className` prop is not honored in `<ReactWebChat>`, by [@compulim](https://github.com/compulim) in PR [#3300](https://github.com/microsoft/BotFramework-WebChat/pull/3300)
4344

4445
### Samples
4546

5.8 KB
Loading
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html lang="en-US">
3+
<head>
4+
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script>
5+
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
6+
<style type="text/css">
7+
.app__webchat {
8+
background-color: palegoldenrod;
9+
}
10+
</style>
11+
</head>
12+
<body>
13+
<div id="webchat"></div>
14+
<script type="text/babel" data-presets="env,stage-3,react">
15+
const { conditions, createStore, expect, host, pageObjects, timeouts, token } = window.WebChatTest;
16+
17+
(async function() {
18+
window.WebChat.renderWebChat(
19+
{
20+
className: 'app__webchat',
21+
directLine: window.WebChat.createDirectLine({ token: await token.fetchDirectLineToken() }),
22+
store: createStore()
23+
},
24+
document.getElementById('webchat')
25+
);
26+
27+
await pageObjects.wait(conditions.uiConnected(), timeouts.directLine);
28+
29+
await host.snapshot();
30+
await host.done();
31+
})().catch(async err => {
32+
console.error(err);
33+
34+
await host.error(err);
35+
});
36+
</script>
37+
</body>
38+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js
3+
*/
4+
5+
describe('simple', () => {
6+
test('should apply "className" prop.', () => runHTMLTest('simple.rootClassName.html'));
7+
});

packages/component/src/BasicWebChat.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import BasicConnectivityStatus from './BasicConnectivityStatus';
1010
import BasicSendBox from './BasicSendBox';
1111
import BasicToaster from './BasicToaster';
1212
import BasicTranscript from './BasicTranscript';
13-
import Composer from './Composer';
1413
import TypeFocusSinkBox from './Utils/TypeFocusSink';
1514
import useDisabled from './hooks/useDisabled';
1615
import useSendBoxFocusRef from './hooks/internal/useSendBoxFocusRef';
@@ -65,11 +64,9 @@ const BasicWebChat = ({ className }) => {
6564
export default BasicWebChat;
6665

6766
BasicWebChat.defaultProps = {
68-
...Composer.defaultProps,
6967
className: ''
7068
};
7169

7270
BasicWebChat.propTypes = {
73-
...Composer.propTypes,
7471
className: PropTypes.string
7572
};

packages/component/src/ReactWebChat.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import PropTypes from 'prop-types';
12
import React from 'react';
23

34
import BasicWebChat from './BasicWebChat';
@@ -11,18 +12,20 @@ import Composer from './Composer';
1112
// - They can run hooks outside of activity/attachment middleware
1213
// - They will put <Composer> as very top of their page, and allow buttons on their existing page to send message to bot
1314

14-
const ReactWebChat = props => (
15-
<Composer {...props}>
16-
<BasicWebChat />
15+
const ReactWebChat = ({ className, ...composerProps }) => (
16+
<Composer {...composerProps}>
17+
<BasicWebChat className={className} />
1718
</Composer>
1819
);
1920

2021
export default ReactWebChat;
2122

2223
ReactWebChat.defaultProps = {
24+
className: undefined,
2325
...Composer.defaultProps
2426
};
2527

2628
ReactWebChat.propTypes = {
29+
className: PropTypes.string,
2730
...Composer.propTypes
2831
};

0 commit comments

Comments
 (0)