Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[fix] fixes for custom input (#3095)
Igor Dykhta21aac1c85103
diff --git a/src/components/src/side-panel/layer-panel/vis-config-slider.tsx b/src/components/src/side-panel/layer-panel/vis-config-slider.tsxindex f6e0e2d16..dae5fea54 100644--- a/src/components/src/side-panel/layer-panel/vis-config-slider.tsx+++ b/src/components/src/side-panel/layer-panel/vis-config-slider.tsx@@ -64,7 +64,7 @@ const CustomInputLabel = styled.label`const RangeInput = styled.input`${props => props.theme.input};font-size: ${props => props.theme.sliderInputFontSize};- width: 44px;+ width: ${props => props.theme.customRangeInputWidth}px;overflow: auto;height: 20px;margin-top: 5px;@@ -82,7 +82,7 @@ const LazyInput: React.FC<LazyInputProps> = ({value, onChange, name}) => {switch (e.keyCode) {case KeyEvent.DOM_VK_ENTER:case KeyEvent.DOM_VK_RETURN:- onChange(stateValue);+ onChange(name, stateValue);if (inputRef !== null) {// @ts-ignoreinputRef?.current.blur();@@ -92,7 +92,7 @@ const LazyInput: React.FC<LazyInputProps> = ({value, onChange, name}) => {break;}},- [onChange, stateValue]+ [onChange, name, stateValue]);const _onChange = useCallback(e => setValue(e.target.value), [setValue]);@@ -114,8 +114,15 @@ const LazyInput: React.FC<LazyInputProps> = ({value, onChange, name}) => {const CustomInput: React.FC<CustomInputProps> = ({isRanged, value, onChangeCustomInput}) => {const onChangeInput = useCallback((name, v) => {- if (isRanged) onChangeCustomInput(name === 'value0' ? [v, value[1]] : [value[0], v]);- else onChangeCustomInput(v);+ const prevValue = isRanged ? (name === 'value1' ? value[0] : value[1]) : value;+ const valueAsNumber = Number(v);+ const convertedValue =+ typeof prevValue === 'number' ? (isNaN(valueAsNumber) ? prevValue : valueAsNumber) : v;+ if (isRanged)+ onChangeCustomInput(+ name === 'value0' ? [convertedValue, value[1]] : [value[0], convertedValue]+ );+ else onChangeCustomInput(convertedValue);},[isRanged, value, onChangeCustomInput]);diff --git a/src/styles/src/base.ts b/src/styles/src/base.tsindex fb1a96050..884102b27 100644--- a/src/styles/src/base.ts+++ b/src/styles/src/base.ts@@ -343,6 +343,9 @@ export const sliderMarginTopIsTime = -12;export const sliderMarginTop = 12;export const sliderMarginBottom = 12;+// Custom Range Input+export const customRangeInputWidth = 100;+// Geocoderexport const geocoderWidth = 360;export const geocoderTop = 20;@@ -1474,6 +1477,9 @@ export const theme = {sliderMarginTop,sliderMarginBottom,+ // Custom Range Input+ customRangeInputWidth,+// GeocodergeocoderWidth,geocoderTop,