react-select-search
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -54,3 +54,3 @@ "use strict"; | ||
"data-index": option.index, | ||
"data-value": option.value, | ||
"data-value": escape(option.value), | ||
key: option.value | ||
@@ -57,0 +57,0 @@ }, comp); |
@@ -14,10 +14,6 @@ "use strict"; | ||
if (!options) { | ||
if (!options || key !== 'ArrowDown' && key !== 'ArrowUp') { | ||
return highlighted; | ||
} | ||
if (key !== 'ArrowDown' && key !== 'ArrowUp') { | ||
return highlighted; | ||
} | ||
var newHighlighted = -1; | ||
@@ -24,0 +20,0 @@ |
@@ -84,3 +84,3 @@ "use strict"; | ||
} else if (snapshot.focus && selectRef.current && snapshot.value) { | ||
selected = selectRef.current.querySelector("[data-value=\"" + snapshot.value.value + "\"]"); | ||
selected = selectRef.current.querySelector("[data-value=\"" + escape(snapshot.value.value) + "\"]"); | ||
} | ||
@@ -87,0 +87,0 @@ |
@@ -189,8 +189,13 @@ "use strict"; | ||
(0, _react.useEffect)(function () { | ||
var option = null; | ||
if (defaultValue && flatDefaultOptions) { | ||
var option = (0, _getOption["default"])(defaultValue, flatDefaultOptions); | ||
setValue(option); | ||
} else if (!defaultValue && flatDefaultOptions && !allowEmpty) { | ||
setValue(flatDefaultOptions[0]); | ||
option = (0, _getOption["default"])(defaultValue, flatDefaultOptions); | ||
} | ||
if (!option && flatDefaultOptions && !allowEmpty) { | ||
option = flatDefaultOptions[0]; | ||
} | ||
setValue(option); | ||
}, [defaultValue]); | ||
@@ -201,2 +206,6 @@ (0, _react.useEffect)(function () { | ||
setFlatDefaultOptions(flatOptions); | ||
if (!value && flatOptions && !allowEmpty) { | ||
setValue(flatOptions[0]); | ||
} | ||
}, [defaultOptions]); | ||
@@ -203,0 +212,0 @@ return [{ |
@@ -44,3 +44,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
"data-index": option.index, | ||
"data-value": option.value, | ||
"data-value": escape(option.value), | ||
key: option.value | ||
@@ -47,0 +47,0 @@ }, comp); |
@@ -11,10 +11,6 @@ export default function highlightReducer(highlighted, value) { | ||
if (!options) { | ||
if (!options || key !== 'ArrowDown' && key !== 'ArrowUp') { | ||
return highlighted; | ||
} | ||
if (key !== 'ArrowDown' && key !== 'ArrowUp') { | ||
return highlighted; | ||
} | ||
let newHighlighted = -1; | ||
@@ -21,0 +17,0 @@ |
@@ -61,3 +61,3 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
} else if (snapshot.focus && selectRef.current && snapshot.value) { | ||
selected = selectRef.current.querySelector("[data-value=\"" + snapshot.value.value + "\"]"); | ||
selected = selectRef.current.querySelector("[data-value=\"" + escape(snapshot.value.value) + "\"]"); | ||
} | ||
@@ -64,0 +64,0 @@ |
@@ -134,8 +134,13 @@ import { useReducer, useEffect, useMemo, useState, useRef } from 'react'; | ||
useEffect(() => { | ||
let option = null; | ||
if (defaultValue && flatDefaultOptions) { | ||
const option = getOption(defaultValue, flatDefaultOptions); | ||
setValue(option); | ||
} else if (!defaultValue && flatDefaultOptions && !allowEmpty) { | ||
setValue(flatDefaultOptions[0]); | ||
option = getOption(defaultValue, flatDefaultOptions); | ||
} | ||
if (!option && flatDefaultOptions && !allowEmpty) { | ||
[option] = flatDefaultOptions; | ||
} | ||
setValue(option); | ||
}, [defaultValue]); | ||
@@ -146,2 +151,6 @@ useEffect(() => { | ||
setFlatDefaultOptions(flatOptions); | ||
if (!value && flatOptions && !allowEmpty) { | ||
setValue(flatOptions[0]); | ||
} | ||
}, [defaultOptions]); | ||
@@ -148,0 +157,0 @@ return [{ |
{ | ||
"name": "react-select-search", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Lightweight select component for React", | ||
@@ -5,0 +5,0 @@ "main": "dist/esm/index.js", |
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
67598
1349