box-ui-elements 23.4.0-beta.28 → 23.4.0-beta.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ import debounce from 'lodash/debounce';
6
6
  import flow from 'lodash/flow';
7
7
  import getProp from 'lodash/get';
8
8
  import noop from 'lodash/noop';
9
+ import throttle from 'lodash/throttle';
9
10
  import uniqueid from 'lodash/uniqueId';
10
11
  import { TooltipProvider } from '@box/blueprint-web';
11
12
  import { AxiosRequestConfig, AxiosResponse } from 'axios';
@@ -1177,7 +1178,7 @@ class ContentExplorer extends Component<ContentExplorerProps, State> {
1177
1178
  * @return {void}
1178
1179
  */
1179
1180
  createFolder = (): void => {
1180
- this.createFolderCallback();
1181
+ this.throttledCreateFolderCallback();
1181
1182
  };
1182
1183
 
1183
1184
  /**
@@ -1243,6 +1244,15 @@ class ContentExplorer extends Component<ContentExplorerProps, State> {
1243
1244
  );
1244
1245
  };
1245
1246
 
1247
+ /**
1248
+ * Throttled version of createFolderCallback to prevent errors from rapid clicking.
1249
+ *
1250
+ * @private
1251
+ * @param {string} [name] - folder name
1252
+ * @return {void}
1253
+ */
1254
+ throttledCreateFolderCallback = throttle(this.createFolderCallback, 500, { trailing: false });
1255
+
1246
1256
  /**
1247
1257
  * Selects the clicked file and then shares it
1248
1258
  *
@@ -1736,7 +1746,7 @@ class ContentExplorer extends Component<ContentExplorerProps, State> {
1736
1746
  {allowCreate && !!this.appElement ? (
1737
1747
  <CreateFolderDialog
1738
1748
  isOpen={isCreateFolderModalOpen}
1739
- onCreate={this.createFolderCallback}
1749
+ onCreate={this.throttledCreateFolderCallback}
1740
1750
  onCancel={this.closeModals}
1741
1751
  isLoading={isLoading}
1742
1752
  errorCode={errorCode}