diff --git a/src/modules/Forms/Controls/RangeNumeric.js b/src/modules/Forms/Controls/RangeNumeric.js index 1aed4237..7dd85f06 100644 --- a/src/modules/Forms/Controls/RangeNumeric.js +++ b/src/modules/Forms/Controls/RangeNumeric.js @@ -12,6 +12,7 @@ class RangeNumeric extends RangeComponent { onNumericInputChange = pos => bound => { const { onChange, min, max } = this.props; const { range } = this.state; + if (Number.isNaN(+bound)) return; // Sanity check that allows typing '-' range[pos] = bound; this.setState({ range }); diff --git a/src/modules/Forms/Controls/RangeNumeric.test.js b/src/modules/Forms/Controls/RangeNumeric.test.js index c495f80b..91b75efa 100644 --- a/src/modules/Forms/Controls/RangeNumeric.test.js +++ b/src/modules/Forms/Controls/RangeNumeric.test.js @@ -8,7 +8,7 @@ jest.mock('@blueprintjs/core', () => ({ Intent: { DANGER: 'danger' }, })); -it('should handle numeric change', async () => { +it('should handle numeric change', () => { const onChange = jest.fn(); const wrapper = mount(); expect(wrapper.find('NumericInput').last().prop('value')).toBe(100); @@ -18,6 +18,13 @@ it('should handle numeric change', async () => { expect(onChange).toHaveBeenCalled(); }); +it('should allow typing minus', () => { + const instance = new RangeNumeric({}); + instance.setState = jest.fn(); + instance.onNumericInputChange(0)('-'); + expect(instance.setState).not.toHaveBeenCalled(); +}); + it('should update range numeric if props are changed', () => { const wrapper = mount(); expect(wrapper.state().range).toEqual([0, 1000]); diff --git a/src/modules/Visualizer/LayersTree/LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js b/src/modules/Visualizer/LayersTree/LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js index d6e07708..45ebcf49 100644 --- a/src/modules/Visualizer/LayersTree/LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js +++ b/src/modules/Visualizer/LayersTree/LayersTreeItem/FiltersPanel/FiltersPanelContent/index.js @@ -2,7 +2,10 @@ import FiltersPanelContent from './FiltersPanelContent'; import { connectLayersTree } from '../../../LayersTreeProvider/context'; -export default connectLayersTree('translate', ({ getLayerState }, { layer, layer: { exclusive, layers } }) => { +export default connectLayersTree(( + { getLayerState, translate }, // context + { layer, layer: { exclusive, layers } }, // props +) => { const activeLayer = exclusive ? layers.find(l => getLayerState({ layer: l }).active) || layer : layer; @@ -10,5 +13,6 @@ export default connectLayersTree('translate', ({ getLayerState }, { layer, layer return { filtersValues: getLayerState({ layer: activeLayer }).filters || {}, activeLayer, + translate, }; })(FiltersPanelContent);