preactjs-templates / material

The material design `preact-cli` template
MIT License
44 stars 20 forks source link

discrete slider onChange return NaN in Chrome #9

Closed digitalica closed 6 years ago

digitalica commented 6 years ago

I'm trying to show the value of a discrete slider in a separate location. Using 'onChange' this workds in Firefox, but Chrome shows NaN.

Also, when using onInput the value in the pin disappears, this time both in Firefox and Chrome.

Code (in home of 'preact create material test'):

import Slider from 'preact-material-components/Slider';
import 'preact-material-components/Slider/style.css';

export default class Home extends Component {

    constructor(props) {
        super(props);
        this.state = {
            value: 10
        }
        this.updateValue = this.updateValue.bind(this);
    }

    updateValue(newValue) {
        this.setState( {
            value: newValue
        })

    }

    render() {
        return (
            <div class={style.home}>
                <h1>Slider test: {this.state.value}</h1>
                <Slider discrete aria-valuemin="0" aria-valuemax="100" aria-valuenow="10" onInput={this.updateValue} />
            </div>
        );
    }
}
digitalica commented 6 years ago

this should probably be an issue in preact-material-components (https://github.com/prateekbh/preact-material-components), not here right? i reproduced using the default template, and adding the preacti material components manually.