I have here some interesting case! I'm using a react-input-range inside a react-leaflet Marker Popup
Which is something like this:
import React from 'react';
import { Map as LeafletMap, Marker, Popup, TileLayer } from 'react-leaflet';
import InputRange from 'react-input-range';
export default class MapPage extends React.Component {
constructor(props) {
super(props);
this.state = {
value: { min: 2, max: 200 },
name: 'sample name',
};
}
render() {
return (
<div>
{/*
* This input range outside LeafletMap works
*/}
<InputRange
maxValue={300}
minValue={0}
value={this.state.value}
onChange={value => this.setState({ value })}
/>
<LeafletMap center={[0, 0]} zoom={16}>
<TileLayer
attribution="© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors"
url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"
/>
<Marker position={[0, 0]}>
<Popup>
{/*
* This input below works
*/}
<input
value={this.state.name}
onChange={({ target }) => this.setState({ name: target.value })}
/>
{/*
* This input range INSIDE LeafletMap does not work
*/}
<InputRange
maxValue={300}
minValue={0}
value={this.state.value}
onChange={value => this.setState({ value })}
/>
</Popup>
</Marker>
</LeafletMap>
</div>
);
}
}
What I know so far
- The
input rangecomponent works outside theLeafletMapcomponent. - Native input works inside the
LeafletMapcomponent! - I've confirmed that a native input works inside the popup! The
input rangeworks on mobile(android chrome browser)! (swipe & click events)
Any ideas how to make input range work inside react-leaflet map?
Here's a few more details that might help:
- react-leaflet: ^2.0.0-rc.3
- react: 16.4.2
- react-input-range: ^1.3.0
Testing Env
Browsers: Chrome 64.0.32, Firefox 61 and Safari 11.1
OS: Mac OSX High Sierra 10.13.5
Codepen: https://codepen.io/codepen-theo/pen/OwdLXY?editors=0010