@@ -6,6 +6,7 @@ import debounce from 'lodash/debounce';
66import flow from 'lodash/flow' ;
77import getProp from 'lodash/get' ;
88import noop from 'lodash/noop' ;
9+ import throttle from 'lodash/throttle' ;
910import uniqueid from 'lodash/uniqueId' ;
1011import { TooltipProvider } from '@box/blueprint-web' ;
1112import { AxiosRequestConfig , AxiosResponse } from 'axios' ;
@@ -1170,16 +1171,6 @@ class ContentExplorer extends Component<ContentExplorerProps, State> {
11701171 ) ;
11711172 } ;
11721173
1173- /**
1174- * Creates a new folder
1175- *
1176- * @private
1177- * @return {void }
1178- */
1179- createFolder = ( ) : void => {
1180- this . createFolderCallback ( ) ;
1181- } ;
1182-
11831174 /**
11841175 * New folder callback
11851176 *
@@ -1243,6 +1234,22 @@ class ContentExplorer extends Component<ContentExplorerProps, State> {
12431234 ) ;
12441235 } ;
12451236
1237+ /**
1238+ * Throttled version of createFolderCallback to prevent errors from rapid clicking.
1239+ * @param {string } [name] - folder name
1240+ */
1241+ throttledCreateFolderCallback = throttle ( this . createFolderCallback , 500 ) ;
1242+
1243+ /**
1244+ * Creates a new folder
1245+ *
1246+ * @private
1247+ * @return {void }
1248+ */
1249+ createFolder = ( ) : void => {
1250+ this . throttledCreateFolderCallback ( ) ;
1251+ } ;
1252+
12461253 /**
12471254 * Selects the clicked file and then shares it
12481255 *
@@ -1738,7 +1745,7 @@ class ContentExplorer extends Component<ContentExplorerProps, State> {
17381745 { allowCreate && ! ! this . appElement ? (
17391746 < CreateFolderDialog
17401747 isOpen = { isCreateFolderModalOpen }
1741- onCreate = { this . createFolderCallback }
1748+ onCreate = { this . throttledCreateFolderCallback }
17421749 onCancel = { this . closeModals }
17431750 isLoading = { isLoading }
17441751 errorCode = { errorCode }
0 commit comments