Skip to content

Commit e30cc31

Browse files
committed
fix warning display
1 parent 1c9b1ad commit e30cc31

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

__tests__/html/fluentTheme/hideAttachFileButton.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
WebChat: { FluentThemeProvider, ReactWebChat }
2121
} = window; // Imports in UMD fashion.
2222

23+
const warnings = [];
24+
const warn = console.warn.bind(console);
25+
console.warn = (message) => {
26+
warnings.push(message);
27+
warn(message);
28+
};
29+
2330
const { directLine, store } = testHelpers.createDirectLineEmulator();
2431

2532
const App = () => (
@@ -34,10 +41,15 @@
3441
);
3542

3643
await pageConditions.uiConnected();
44+
45+
expect(warnings).toEqual([
46+
'Web Chat: "hideUploadButton" is deprecated. Please use "disableFileUpload" instead.'
47+
]);
3748

3849
// THEN: No attach button should be render.
3950
expect(pageElements.byTestId(WebChat.testIds.sendBoxUploadButton)).toBeFalsy();
4051
await host.snapshot();
52+
4153
});
4254
</script>
4355
</body>

packages/api/src/StyleOptions.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,12 @@ type StyleOptions = {
10021002
type StrictStyleOptions = Required<
10031003
Omit<
10041004
StyleOptions,
1005-
'bubbleImageHeight' | 'bubbleMaxWidth' | 'bubbleMinWidth' | 'hideScrollToEndButton' | 'newMessagesButtonFontSize'
1005+
| 'bubbleImageHeight'
1006+
| 'bubbleMaxWidth'
1007+
| 'bubbleMinWidth'
1008+
| 'hideScrollToEndButton'
1009+
| 'hideUploadButton'
1010+
| 'newMessagesButtonFontSize'
10061011
>
10071012
> & {
10081013
bubbleFromUserNubOffset: number;

packages/api/src/defaultStyleOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const DEFAULT_OPTIONS: Required<StyleOptions> = {
101101
disableFileUpload: false,
102102
hideSendBox: false,
103103
hideTelephoneKeypadButton: true,
104-
hideUploadButton: false,
104+
hideUploadButton: undefined, // Deprecated as of 4.19.0.
105105
microphoneButtonColorOnDictate: '#F33',
106106
sendAttachmentOn: 'send',
107107
sendBoxBackground: 'White',

packages/api/src/patchStyleOptionsFromDeprecatedProps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function patchStyleOptionsFromDeprecatedProps(styleOptions) {
1111
}
1212

1313
// Rectify deprecated "hideUploadButton" into "disableFileUpload"
14-
if ('hideUploadButton' in styleOptions && !('disableFileUpload' in styleOptions)) {
14+
if (styleOptions.hideUploadButton !== undefined) {
1515
console.warn('Web Chat: "hideUploadButton" is deprecated. Please use "disableFileUpload" instead.');
1616

1717
styleOptions = updateIn(styleOptions, ['disableFileUpload'], () => !!styleOptions.hideUploadButton);

0 commit comments

Comments
 (0)