rc-select
Advanced tools
Comparing version 14.15.0 to 14.15.1
@@ -12,3 +12,2 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import isMobile from "rc-util/es/isMobile"; | ||
import KeyCode from "rc-util/es/KeyCode"; | ||
import { useComposeRef } from "rc-util/es/ref"; | ||
@@ -271,2 +270,3 @@ import * as React from 'react'; | ||
setClearLock = _useLock2[1]; | ||
var keyLockRef = React.useRef(false); | ||
@@ -276,4 +276,5 @@ // KeyDown | ||
var clearLock = getClearLock(); | ||
var which = event.which; | ||
if (which === KeyCode.ENTER) { | ||
var key = event.key; | ||
var isEnterKey = key === 'Enter'; | ||
if (isEnterKey) { | ||
// Do not submit form when type in the input | ||
@@ -292,3 +293,3 @@ if (mode !== 'combobox') { | ||
// Remove value by `backspace` | ||
if (which === KeyCode.BACKSPACE && !clearLock && multiple && !mergedSearchValue && displayValues.length) { | ||
if (key === 'Backspace' && !clearLock && multiple && !mergedSearchValue && displayValues.length) { | ||
var cloneDisplayValues = _toConsumableArray(displayValues); | ||
@@ -314,6 +315,9 @@ var removedDisplayValue = null; | ||
} | ||
if (mergedOpen) { | ||
if (mergedOpen && (!isEnterKey || !keyLockRef.current)) { | ||
var _listRef$current2; | ||
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 || _listRef$current2.onKeyDown.apply(_listRef$current2, [event].concat(rest)); | ||
} | ||
if (isEnterKey) { | ||
keyLockRef.current = true; | ||
} | ||
onKeyDown === null || onKeyDown === void 0 || onKeyDown.apply(void 0, [event].concat(rest)); | ||
@@ -331,2 +335,5 @@ }; | ||
} | ||
if (event.key === 'Enter') { | ||
keyLockRef.current = false; | ||
} | ||
onKeyUp === null || onKeyUp === void 0 || onKeyUp.apply(void 0, [event].concat(rest)); | ||
@@ -333,0 +340,0 @@ }; |
@@ -19,3 +19,2 @@ "use strict"; | ||
var _isMobile = _interopRequireDefault(require("rc-util/lib/isMobile")); | ||
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode")); | ||
var _ref2 = require("rc-util/lib/ref"); | ||
@@ -281,2 +280,3 @@ var React = _interopRequireWildcard(require("react")); | ||
setClearLock = _useLock2[1]; | ||
var keyLockRef = React.useRef(false); | ||
@@ -286,4 +286,5 @@ // KeyDown | ||
var clearLock = getClearLock(); | ||
var which = event.which; | ||
if (which === _KeyCode.default.ENTER) { | ||
var key = event.key; | ||
var isEnterKey = key === 'Enter'; | ||
if (isEnterKey) { | ||
// Do not submit form when type in the input | ||
@@ -302,3 +303,3 @@ if (mode !== 'combobox') { | ||
// Remove value by `backspace` | ||
if (which === _KeyCode.default.BACKSPACE && !clearLock && multiple && !mergedSearchValue && displayValues.length) { | ||
if (key === 'Backspace' && !clearLock && multiple && !mergedSearchValue && displayValues.length) { | ||
var cloneDisplayValues = (0, _toConsumableArray2.default)(displayValues); | ||
@@ -324,6 +325,9 @@ var removedDisplayValue = null; | ||
} | ||
if (mergedOpen) { | ||
if (mergedOpen && (!isEnterKey || !keyLockRef.current)) { | ||
var _listRef$current2; | ||
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 || _listRef$current2.onKeyDown.apply(_listRef$current2, [event].concat(rest)); | ||
} | ||
if (isEnterKey) { | ||
keyLockRef.current = true; | ||
} | ||
onKeyDown === null || onKeyDown === void 0 || onKeyDown.apply(void 0, [event].concat(rest)); | ||
@@ -341,2 +345,5 @@ }; | ||
} | ||
if (event.key === 'Enter') { | ||
keyLockRef.current = false; | ||
} | ||
onKeyUp === null || onKeyUp === void 0 || onKeyUp.apply(void 0, [event].concat(rest)); | ||
@@ -343,0 +350,0 @@ }; |
{ | ||
"name": "rc-select", | ||
"version": "14.15.0", | ||
"version": "14.15.1", | ||
"description": "React Select", | ||
@@ -37,3 +37,3 @@ "engines": { | ||
"compile": "father build && lessc assets/index.less assets/index.css", | ||
"prepublishOnly": "npm run compile && np --yolo --no-publish", | ||
"prepublishOnly": "npm run compile", | ||
"lint": "eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js", | ||
@@ -40,0 +40,0 @@ "test": "rc-test", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
341395
7448