dce-reactkit 3.4.0-beta.4 → 3.4.0-beta.6

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.4.0-beta.4",
3
+ "version": "3.4.0-beta.6",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -56,32 +56,24 @@ let storedSendRequest: SendRequestFunction;
56
56
  * @returns sendRequest function
57
57
  */
58
58
  export const getSendRequest = async () => {
59
- // Track timeout
60
- let timedOut = false;
59
+ // Show timeout error if too much time passes
60
+ let successful = false;
61
61
  (async () => {
62
62
  await waitMs(5000);
63
- timedOut = true;
63
+
64
+ if (!successful) {
65
+ showFatalError(
66
+ new ErrorWithCode(
67
+ 'Could not send a request because the request needed to be sent before dce-reactkit was properly initialized. Perhaps dce-reactkit was not initialized with initClient.',
68
+ ReactKitErrorCode.NoCACCLSendRequestFunction,
69
+ ),
70
+ );
71
+ }
64
72
  })(),
65
73
 
66
74
  // Wait for initialization
67
75
  await initialized;
68
-
69
- // Error if no send request function
70
- if (timedOut) {
71
- showFatalError(
72
- new ErrorWithCode(
73
- 'Could not send a request because the request needed to be sent before dce-reactkit was properly initialized. Perhaps dce-reactkit was not initialized with initClient.',
74
- ReactKitErrorCode.NoCACCLSendRequestFunction,
75
- ),
76
- );
77
-
78
- // Return dummy function that never resolves
79
- return (
80
- () => {
81
- return new Promise(() => {});
82
- }
83
- ) as SendRequestFunction;
84
- }
76
+ successful = true;
85
77
 
86
78
  // Return
87
79
  return storedSendRequest;
@@ -434,4 +434,4 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
434
434
  /*------------------------------------------------------------------------*/
435
435
 
436
436
  // Export component
437
- export default AppWrapper;
437
+ export default AppWrapper;
@@ -196,7 +196,6 @@ const CreatableMultiselect: React.FC<Props> = (props) => {
196
196
  * @param event keyboard event
197
197
  */
198
198
  const handleKeyDown: KeyboardEventHandler = (event) => {
199
- event.preventDefault();
200
199
 
201
200
  // Skip if no input value
202
201
  if (!inputValue) {
@@ -205,6 +204,7 @@ const CreatableMultiselect: React.FC<Props> = (props) => {
205
204
 
206
205
  // Add values if enter or tab is pressed
207
206
  if (['Enter', 'Tab'].includes(event.key)) {
207
+ event.preventDefault();
208
208
  addValues(inputValue);
209
209
  }
210
210
  };