@reltio/components 1.4.2119 → 1.4.2120
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.
|
@@ -199,7 +199,7 @@ export var TypeaheadEditor = function (_a) {
|
|
|
199
199
|
}
|
|
200
200
|
}, [multiple, onChange, value]);
|
|
201
201
|
var handleKeyDown = useCallback(function (event) {
|
|
202
|
-
if (event.
|
|
202
|
+
if (event.key !== 'Enter' || highlightedItem)
|
|
203
203
|
return;
|
|
204
204
|
if (multiple === true) {
|
|
205
205
|
handleInputValueChange({ method: ChangeMethod.Enter, newValue: inputValue });
|
|
@@ -209,9 +209,13 @@ export var TypeaheadEditor = function (_a) {
|
|
|
209
209
|
}
|
|
210
210
|
}, [handleInputValueChange, onChange, highlightedItem, inputValue, multiple]);
|
|
211
211
|
var handleBlur = useCallback(function () {
|
|
212
|
-
if (multiple !== true)
|
|
212
|
+
if (multiple !== true) {
|
|
213
213
|
onChange(inputValue);
|
|
214
|
-
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
handleInputValueChange({ method: ChangeMethod.Enter, newValue: inputValue });
|
|
217
|
+
}
|
|
218
|
+
}, [inputValue, onChange, multiple, handleInputValueChange]);
|
|
215
219
|
useEffect(function () {
|
|
216
220
|
var _a;
|
|
217
221
|
if (multiple !== true)
|
|
@@ -224,7 +228,7 @@ export var TypeaheadEditor = function (_a) {
|
|
|
224
228
|
container: fullWidth ? styles.suggestionsContainer : '',
|
|
225
229
|
suggestionsList: styles.suggestionsList,
|
|
226
230
|
suggestionsContainerOpen: styles.suggestionsContainerOpen
|
|
227
|
-
}, inputProps: __assign({ value: inputValue, onChange: pipe(nthArg(1), handleInputValueChange), onKeyDown: handleKeyDown, onBlur: handleBlur, fullWidth: fullWidth, variant: 'standard', autoComplete: '
|
|
231
|
+
}, inputProps: __assign({ value: inputValue, onChange: pipe(nthArg(1), handleInputValueChange), onKeyDown: handleKeyDown, onBlur: handleBlur, fullWidth: fullWidth, variant: 'standard', autoComplete: 'off' }, inputProps), renderInputComponent: function (_a) {
|
|
228
232
|
var _b, _c;
|
|
229
233
|
var ref = _a.ref, otherProps = __rest(_a, ["ref"]);
|
|
230
234
|
var commonClasses = {
|
|
@@ -421,6 +421,28 @@ describe('TypeaheadEditor', function () {
|
|
|
421
421
|
}
|
|
422
422
|
});
|
|
423
423
|
}); });
|
|
424
|
+
it('should add chip correctly on input blur', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
425
|
+
var values, props, user, input;
|
|
426
|
+
return __generator(this, function (_a) {
|
|
427
|
+
switch (_a.label) {
|
|
428
|
+
case 0:
|
|
429
|
+
values = ['value 1', 'value 2'];
|
|
430
|
+
props = __assign(__assign({}, defaultMultipleProps), { value: values });
|
|
431
|
+
user = setUp(props).user;
|
|
432
|
+
input = screen.getByRole('textbox');
|
|
433
|
+
return [4 /*yield*/, user.type(input, 'value 3')];
|
|
434
|
+
case 1:
|
|
435
|
+
_a.sent();
|
|
436
|
+
expect(input).toHaveAttribute('value', 'value 3');
|
|
437
|
+
return [4 /*yield*/, user.tab()];
|
|
438
|
+
case 2:
|
|
439
|
+
_a.sent(); // simulating input blur
|
|
440
|
+
expect(input).toHaveAttribute('value', '');
|
|
441
|
+
expect(props.onChange).toHaveBeenCalledWith(['value 1', 'value 2', 'value 3']);
|
|
442
|
+
return [2 /*return*/];
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
}); });
|
|
424
446
|
it('should add chip correctly after select suggestion item using keyboard', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
425
447
|
var values, props, user, input;
|
|
426
448
|
return __generator(this, function (_a) {
|
|
@@ -228,7 +228,7 @@ var TypeaheadEditor = function (_a) {
|
|
|
228
228
|
}
|
|
229
229
|
}, [multiple, onChange, value]);
|
|
230
230
|
var handleKeyDown = (0, react_1.useCallback)(function (event) {
|
|
231
|
-
if (event.
|
|
231
|
+
if (event.key !== 'Enter' || highlightedItem)
|
|
232
232
|
return;
|
|
233
233
|
if (multiple === true) {
|
|
234
234
|
handleInputValueChange({ method: ChangeMethod.Enter, newValue: inputValue });
|
|
@@ -238,9 +238,13 @@ var TypeaheadEditor = function (_a) {
|
|
|
238
238
|
}
|
|
239
239
|
}, [handleInputValueChange, onChange, highlightedItem, inputValue, multiple]);
|
|
240
240
|
var handleBlur = (0, react_1.useCallback)(function () {
|
|
241
|
-
if (multiple !== true)
|
|
241
|
+
if (multiple !== true) {
|
|
242
242
|
onChange(inputValue);
|
|
243
|
-
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
handleInputValueChange({ method: ChangeMethod.Enter, newValue: inputValue });
|
|
246
|
+
}
|
|
247
|
+
}, [inputValue, onChange, multiple, handleInputValueChange]);
|
|
244
248
|
(0, react_1.useEffect)(function () {
|
|
245
249
|
var _a;
|
|
246
250
|
if (multiple !== true)
|
|
@@ -253,7 +257,7 @@ var TypeaheadEditor = function (_a) {
|
|
|
253
257
|
container: fullWidth ? styles.suggestionsContainer : '',
|
|
254
258
|
suggestionsList: styles.suggestionsList,
|
|
255
259
|
suggestionsContainerOpen: styles.suggestionsContainerOpen
|
|
256
|
-
}, inputProps: __assign({ value: inputValue, onChange: (0, ramda_1.pipe)((0, ramda_1.nthArg)(1), handleInputValueChange), onKeyDown: handleKeyDown, onBlur: handleBlur, fullWidth: fullWidth, variant: 'standard', autoComplete: '
|
|
260
|
+
}, inputProps: __assign({ value: inputValue, onChange: (0, ramda_1.pipe)((0, ramda_1.nthArg)(1), handleInputValueChange), onKeyDown: handleKeyDown, onBlur: handleBlur, fullWidth: fullWidth, variant: 'standard', autoComplete: 'off' }, inputProps), renderInputComponent: function (_a) {
|
|
257
261
|
var _b, _c;
|
|
258
262
|
var ref = _a.ref, otherProps = __rest(_a, ["ref"]);
|
|
259
263
|
var commonClasses = {
|
|
@@ -426,6 +426,28 @@ describe('TypeaheadEditor', function () {
|
|
|
426
426
|
}
|
|
427
427
|
});
|
|
428
428
|
}); });
|
|
429
|
+
it('should add chip correctly on input blur', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
430
|
+
var values, props, user, input;
|
|
431
|
+
return __generator(this, function (_a) {
|
|
432
|
+
switch (_a.label) {
|
|
433
|
+
case 0:
|
|
434
|
+
values = ['value 1', 'value 2'];
|
|
435
|
+
props = __assign(__assign({}, defaultMultipleProps), { value: values });
|
|
436
|
+
user = setUp(props).user;
|
|
437
|
+
input = react_2.screen.getByRole('textbox');
|
|
438
|
+
return [4 /*yield*/, user.type(input, 'value 3')];
|
|
439
|
+
case 1:
|
|
440
|
+
_a.sent();
|
|
441
|
+
expect(input).toHaveAttribute('value', 'value 3');
|
|
442
|
+
return [4 /*yield*/, user.tab()];
|
|
443
|
+
case 2:
|
|
444
|
+
_a.sent(); // simulating input blur
|
|
445
|
+
expect(input).toHaveAttribute('value', '');
|
|
446
|
+
expect(props.onChange).toHaveBeenCalledWith(['value 1', 'value 2', 'value 3']);
|
|
447
|
+
return [2 /*return*/];
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
}); });
|
|
429
451
|
it('should add chip correctly after select suggestion item using keyboard', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
430
452
|
var values, props, user, input;
|
|
431
453
|
return __generator(this, function (_a) {
|